PHP collection tool Snoopy trial experience_PHP tutorial
What is Snoopy? (Download snoopy)
Snoopy is a php class that is used to imitate the functions of a web browser. It can complete the tasks of obtaining web page content and sending forms.
Some features of Snoopy:
* Convenient to crawl the content of web pages
* Convenient to crawl the text content of web pages (removing HTML tags)
* Convenient to crawl links of web pages
* Support proxy Host
* Supports basic username/password authentication
* Supports setting user_agent, referer (source), cookies and header content (header file)
* Supports browser redirection and can control the redirection depth
* Can expand links in web pages into high-quality URLs (default)
* Convenient to submit data and obtain return values
* Support tracking HTML framework (added in v0.92)
* Support redirection When passing cookies (added in v0.92)
If you want to know more deeply, Google it yourself. Here are a few simple examples:
1 Get the content of the specified url
PHP code
$url = "http://www.jb51.net";
include("snoopy.php");
$snoopy = new Snoopy;
$snoopy->fetch( $url); //Get all content
echo $snoopy->results; //Display results
$snoopy->fetchtext //Get text content (remove html code)
$snoopy-> ;fetchlinks //Get links
$snoopy->fetchform //Get form
2 form submission
PHP code
$formvars["username"] = "admin";
$formvars["pwd"] = "admin";
$action = "http://www.jb51.net";//Form submission address
$snoopy->submit($action,$formvars);//$formvars is the submitted array
echo $snoopy- >results; //Get the results returned after form submission
$snoopy->submittext; //Only return the text without HTML after submission
$snoopy->submitlinks;//Only return after submission Link
Now that the form has been submitted, you can do a lot of things. Next, let’s disguise the IP and browser
3. Disguise
PHP code
$formvars["username"] = "admin";
$formvars["pwd"] = "admin";
$action = "http://www.jb51.net";
include "snoopy.php";
$snoopy = new Snoopy;
$snoopy->cookies["PHPSESSID" ] = 'fc106b1918bd522cc863f36890e6fff7'; //Disguise sessionid
$snoopy->agent = "(compatible; MSIE 4.01; MSN 2.5; AOL 4.0; Windows 98)"; //Disguise browser
$snoopy-> ;referer = "http://s.jb51.net"; //Disguise source page address http_referer
$snoopy->rawheaders["Pragma"] = "no-cache"; //cache's http header information
$snoopy->rawheaders["X_FORWARDED_FOR"] = "127.0.0.101"; //Disguise ip
$snoopy->submit($action,$formvars);
echo $snoopy-> ;results;
It turns out that we can camouflage session, camouflage browser, camouflage IP, haha, we can do a lot of things.
For example, if you vote with a verification code and IP address, you can vote continuously.
ps: Disguising the IP here is actually disguising the http header, so the IP obtained through REMOTE_ADDR cannot be disguised.
On the contrary, those who obtain the IP through the http header (the kind that can prevent proxying) can do it themselves to create ip.
A brief explanation of how to verify the code:
First use an ordinary browser to view the page and find the sessionid corresponding to the verification code.
Write down the sessionid and verification code values at the same time.
Next Just use snoopy to fake it.
Principle: Since it is the same sessionid, the verification code obtained is the same as the one entered for the first time.
4 Sometimes we may need to forge more things, snoopy completely thought of it for us
PHP code
$snoopy->proxy_host = "www.jb51.net";
$snoopy->proxy_port = "8080"; //Use proxy
$snoopy->maxredirs = 2; //Number of redirections
$snoopy->expandlinks = true; //Whether the completion link is often used during collection
// For example, the link is /images/taoav.gif, which can be changed to it The full link http://www.jb51.net/images/taoav.gif, this place can actually be replaced by the ereg_replace function during the final output
$snoopy->maxframes = 5 //Maximum frames allowed Number
//Note that when grabbing the frame, $snoopy->results returns an array
$snoopy->error //Returns error message
Basic usage above Got it, let me demonstrate it with an example:
PHP code
//echo var_dump($_SERVER);
include("Snoopy.class.php");
$snoopy = new Snoopy;
$snoopy- >agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-
CN; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 FirePHP/0.2.1";//This is Browser information
information, which browser you used to view cookies earlier, use that browser’s information (ps:$_SERVER can view the browser information)
$snoopy->referer = "http: //bbs.jb51.net/index.php";
$snoopy->expandlinks = true;
$snoopy->rawheaders["COOKIE"]="__utmz=17229162.1227682761.29.7.utmccn=( referral)|utmcsr=jb51.net|utmcct=/html/index.html|utmcmd=referral; cdbphpchina_smile=1D2D0D1; cdbphpchina_cookietime=2592000; __utma=233700831.1562900865.1227113506.1229613449.12 31233266.16; __utmz=233700831.1231233266.16.8.utmccn=(referral)| utmcsr=localhost:8080|utmcct=/test3.php|utmcmd=referral; __utma=17229162.1877703507.1227113568.1231228465.1231233160.58; uchome_loginuser=sinopf; xscdb_cookietime=259200 0; __utmc=17229162; __utmb=17229162; cdbphpchina_sid=EX5w1V; __utmc=233700831; cdbphpchina_visitedfid =17; cdbphpchinaO766uPYGK6OWZaYlvHSuzJIP22VpwEMGnPQAuWCFL9Fd6CHp2e%2FKw0x4bKz0N9lGk; ZrVKgqPOttHVr%2B6KLPg3DtWpTMUI4ttqNNVpukUj6ElM; cdbphpchina_onlineusernum=3721";
$snoopy->fetch("http://bbs.jb51.net");
$n=ereg_replace("href="","href="http://bbs.jb51.net/",$snoopy->results );
echo ereg_replace("src="","src= "http://bbs.jb51.net/",$n);
?>
This is the process of simulating logging into the PHPCHINA forum. You must first check your browser's information
Message: echo var_dump($_SERVER); This code can see the information of your browser. Copy the content after
$_SERVER['HTTP_USER_AGENT'] and paste it in the $snoopy->agent area. , and then you need to check your own
COOKIE. After logging in to the forum with your own forum account, enter
javascript:document.write(document.cookie) in the browser address bar, press Enter, and you can view it. Go to your own cookie information, copy and paste
after $snoopy->rawheaders["COOKIE"]=. (My cookie information has been deleted for security reasons)
Then pay attention to:
# $n=ereg_replace("href="","href="http:// bbs.jb51.net/",$snoopy->results );
# echo ereg_replace("src="","src="http://bbs.jb51.net/",$n );
These two lines of code, because all the HTML source addresses of the collected content are relative links, should be replaced with absolute links, so that the pictures and css styles of the forum can be quoted.

PHP remains a powerful and widely used tool in modern programming, especially in the field of web development. 1) PHP is easy to use and seamlessly integrated with databases, and is the first choice for many developers. 2) It supports dynamic content generation and object-oriented programming, suitable for quickly creating and maintaining websites. 3) PHP's performance can be improved by caching and optimizing database queries, and its extensive community and rich ecosystem make it still important in today's technology stack.

In PHP, weak references are implemented through the WeakReference class and will not prevent the garbage collector from reclaiming objects. Weak references are suitable for scenarios such as caching systems and event listeners. It should be noted that it cannot guarantee the survival of objects and that garbage collection may be delayed.

The \_\_invoke method allows objects to be called like functions. 1. Define the \_\_invoke method so that the object can be called. 2. When using the $obj(...) syntax, PHP will execute the \_\_invoke method. 3. Suitable for scenarios such as logging and calculator, improving code flexibility and readability.

Fibers was introduced in PHP8.1, improving concurrent processing capabilities. 1) Fibers is a lightweight concurrency model similar to coroutines. 2) They allow developers to manually control the execution flow of tasks and are suitable for handling I/O-intensive tasks. 3) Using Fibers can write more efficient and responsive code.

The PHP community provides rich resources and support to help developers grow. 1) Resources include official documentation, tutorials, blogs and open source projects such as Laravel and Symfony. 2) Support can be obtained through StackOverflow, Reddit and Slack channels. 3) Development trends can be learned by following RFC. 4) Integration into the community can be achieved through active participation, contribution to code and learning sharing.

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP is not dying, but constantly adapting and evolving. 1) PHP has undergone multiple version iterations since 1994 to adapt to new technology trends. 2) It is currently widely used in e-commerce, content management systems and other fields. 3) PHP8 introduces JIT compiler and other functions to improve performance and modernization. 4) Use OPcache and follow PSR-12 standards to optimize performance and code quality.

The future of PHP will be achieved by adapting to new technology trends and introducing innovative features: 1) Adapting to cloud computing, containerization and microservice architectures, supporting Docker and Kubernetes; 2) introducing JIT compilers and enumeration types to improve performance and data processing efficiency; 3) Continuously optimize performance and promote best practices.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version
Chinese version, very easy to use

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function