Home  >  Article  >  Backend Development  >  Small example of using Snoopy class_PHP tutorial

Small example of using Snoopy class_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:52:41868browse

Snoopy is a PHP class that is used to imitate the functions of a web browser. It can complete the tasks of obtaining web content and sending forms.
The following are some of its features:
1. Convenient to crawl the content of web pages
2. Convenient to crawl text of web pages (remove HTML code)
3. Convenient to crawl links of web pages
4. Support proxy host
5. Support basic user/password authentication mode
6. Support custom user agent, referer, cookies and header content
7. Support browser redirection and control the redirection Depth
8. Can expand links in web pages into high-quality URLs (default)
9. Conveniently submit data and obtain return values
10. Support tracking HTML framework (added in v0.92)
11. Supports passing cookies when redirecting

Please see the instructions in the download file for specific usage.

Copy code The code is as follows:

include "Snoopy.class.php" ;
$snoopy = new Snoopy;
$snoopy->fetchform("http://www.phpx.com/happy/logging.php?action=login");
print $snoopy- >results;
< ?php
include "Snoopy.class.php";
$snoopy = new Snoopy;
$submit_url = "http://www.phpx.com/happy /logging.php?action=login";

$submit_vars["loginmode"] = "normal";
$submit_vars["styleid"] = "1";
$submit_vars[" cookietime"] = "315360000";
$submit_vars["loginfield"] = "username";
$submit_vars["username"] = "********"; //Your user Name
$submit_vars["password"] = "*******"; //Your password
$submit_vars["questionid"] = "0";
$submit_vars["answer "] = "";
$submit_vars["loginsubmit"] = "Submit";
$snoopy->submit($submit_url,$submit_vars);
print $snoopy->results;

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/318863.htmlTechArticlesnoopy is a php class that is used to imitate the functions of a web browser. It can complete obtaining web content and sending forms task. The following are some of its features: 1. It is convenient to crawl the content of web pages...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn