Introduction: This is a powerful php collection tool: Snoopy trial details page, introduced and PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 339654 'rolling = 'no'> What Is Snoopy? (Download Snoopy) Snoopy is a PHP class used to imitate the functions of a Web browser. It can complete the task of obtaining webpage content and sending forms. Some features of Snoopy: * convenient crawling of webpage content * convenient crawling of webpage text content (remove HTML tags) * convenient webpage crawling * Support proxy host * support basic username/password verification * Support user_agent, Referer (lailu), cookies and header content (header file) * Support browser redirection, and can control the redirection depth * extend the link in the webpage to a high-quality URL (default) * facilitate data submission and obtain returned values * support tracking HTML framework (added in v0.92) * If you want to learn more about sending cookies when you switch back (v0.92 is added), Google it yourself. Below are a few simple examples: 1 get the specified URL content PHPCode
$ Url = "http://www.taoav.com"; Include ("Snoopy. PHP "); $ Snoopy = new Snoopy; $ Snoopy-> fetch ($ URL); // obtain all content echo $ Snoopy-> results; // display the result $ Snoopy-> fetchtext // obtain the text content (remove the HTML code) $ Snoopy-> fetchlinks // obtain the link $ Snoopy-> fetchform // obtain the form
2. Submit PHP code in a form
$ Formvars ["username"] = "admin"; $ formvars ["PWD"] = "admin"; $ action = "http://www.taoav.com "; // form submission address $ Snoopy-> submit ($ action, $ formvars); // $ formvars is the submitted array echo $ Snoopy-> results; // obtain the result returned after the form is submitted $ Snoopy-> submittext; // After the form is submitted, only the HTML-removed text $ Snoopy-> submitlinks is returned. // After the form is submitted, only the link is returned.
Now that you have submitted the form, you can do a lot of things. Next we will disguise the IP address and the browser 3 as the PHP code.
$ Formvars ["username"] = "admin"; $ formvars ["PWD"] = "admin"; $ action = "http://www.taoav.com"; Include "Snoopy. PHP "; $ Snoopy = new Snoopy; $ Snoopy-> Cookies [" PHPSESSID "] = 'fc0000b1918bd522cc863f000090e6fff7 '; // disguise sessionid $ Snoopy-> agent =" (compatible; MSIE 4.01; MSN 2.5; AOL 4.0; Windows 98) "; // camouflage browser $ Snoopy-> Referer =" http://www.only4.cn "; // disguise the Source Page address http_referer $ Snoopy-> rawheaders ["Pragma"] = "no-Cache "; // Cache HTTP header information $ Snoopy-> rawheaders ["x_forwarded_for"] = "127.0.0.101"; // disguise IP $ Snoopy-> submit ($ action, $ formvars ); echo $ Snoopy-> results;
- In the past, we could disguise session as a Web browser and IP address, and Haha could do a lot of things.
For example, you can vote for an IP address with a verification code. PS: here, the disguised IP address is actually an HTTP header. Therefore, the IP address obtained through remote_addr cannot be disguised, but those obtained through the HTTP header (which can prevent proxy) you can create an IP address by yourself. Let's briefly describe how to use the verification code. First, use a common browser to view the page, find the sessionid corresponding to the Verification code, and write down the sessionid and the verification code value. Then, use Snoopy to forge the verification code. Principle: because 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 comes up with PHP code for us.
$ Snoopy-> proxy_host = "www.only4.cn"; $ Snoopy-> proxy_port = "8080"; // use the proxy $ Snoopy-> maxredirs = 2; // redirect times $ Snoopy-> expandlinks = true; // whether to enable the full link is frequently used during collection. // For example, if the link is/images/taoav.gif, you can change it to its full-link scheme $ Snoopy-> maxframes = 5 // maximum allowed frame. // when capturing the framework, $ Snoopy-> results returns an array $ Snoopy-> error // returns an error message.
The above basic usage is understood. I will demonstrate the PHP code once in the following example:
<? // 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 the browser information. You can use the browser to view the cookie (PS: $ _ server can view browser information) $ Snoopy-> Referer = "http://bbs.phpchina.com/index.php"; $ Snoopy-> expandlinks = true; $ Snoopy-> rawheaders ["cookie"] = "_ utmz = 17229162.12 Response = (referral) | utmcsr = phpchina.com | utmcct =/html/index.html | utmcmd = referral; cdbphpchina_smile = 1d2d0d1; cdbphpchina_cookietime = 2592000; _ utma = Beijing; _ utmz = 233700831.1231233266.16.8.utmccn = (referral) | utmcsr = localhost: 8080 | utmcct =/test3.php | utmcmd = referral; _ utma = Shanghai; uchome_logi Nuser = sinopf; xscdb_cookietime = 2592000; _ utmc = 17229162; _ utmb = 17229162; cdbphpchina_sid = ex5w1v; _ utmc = 233700831; cdbphpchina_visitedfid = 17; %% response; xscdb_auth = 8127rayhkpql49ems % 2fyhlbf3c6clz % pushed % 2 bhszrvkgqpotthvr % pushed; cdbphpchina_onlineusernum = 3721 "; $ Snoopy-> fetch (" http://bbs.phpch Ina.com/forum-17-1.html "); $ n = ereg_replace (" href = \ "", "href = \" http://bbs.phpchina.com/", $ Snoopy-> results ); echo ereg_replace ("src = \" "," src = \ "http://bbs.phpchina.com/", $ n);?>This is the process of simulating login to the phpchina Forum. First, you must view your browser emails.
Information: Echo var_dump ($ _ server); this code can view your browser information
Copy the content behind $ _ server ['HTTP _ user_agent '] and stick it to $ Snoopy-> agent. Then you need to check your own
Cookie. After logging on to the forum with your own account, enter
Javascript: Document. Write (document. Cookie). Press enter to view your cookie information and copy and paste it.
To the back of $ Snoopy-> rawheaders ["cookie"] =. (My cookie information has been deleted for security reasons)
Then pay attention:
# $ N = ereg_replace ("href = \" "," href = \ "http://bbs.phpchina.com/", $ Snoopy-> results );
# Echo ereg_replace ("src = \" "," src = \ "http://bbs.phpchina.com/", $ N );
Because all the HTML source code addresses of the collected content are relative links, replace them with absolute links so that you can reference the Forum images and CSS styles. Reprinted: http://zzdboy1616.blog.163.com/blog/static/430670762009213111712876/
Love J2EE follow Java Michael Jackson video station JSON online tools
http://biancheng.dnbcw.info/php/339654.html pageno: 7