Home > Article > Backend Development > Analysis of the characteristics of PHP class Snoopy_PHP tutorial
Everyone knows what is the PHP class Snoopy in ?
Snoopy is a php class that is used to imitate the functions of a web browser. It Able to complete tasks of obtaining web page content and sending forms.
Some features of PHP Snoopy:
* Convenient to crawl the content of web pages
* Convenient to crawl the text content of web pages (removing HTML tags)
* Convenient to crawl web links
* Support proxy host
* Support basic username/password verification
* Support setting user_agent, referer (source), cookies and header content (header file)
* Supports browser redirection and can control redirection depth
* Can expand links in web pages into high-quality URLs (default)
* Conveniently submit data and obtain return values
* Support tracking HTML Framework (added in v0.92)
* Supports passing cookies when redirecting (added in v0.92)
The correct operation of the PHP class Snoopy requires that your server's PHP version is 4 or above and supports PCRE ( Perl Compatible Regular Expressions), basic LAMP services are supported.
It provides the following interfaces or methods:
fetch($URI)
This method is to crawl the content of the web page, $URI is to crawl the web page The URL is fetched and the results are stored in $this->results. If you capture frames, each frame will be captured and the results will be saved in an array.
fetchtext($URI)
This method is roughly the same as fetch(), except that its result is text, removing HTML tags and other irrelevant information.
fetchform($URI)
This method only returns the form element on the fetched web page.
fetchlinks($URI)
This method only returns links on the crawled web page. By default, the links returned are links containing domain names.
submit($URI,$formvars)
This method submits a form to the specified $URI. $formvars is an array of form variables to be passed.
submittext($URI,$formvars)
This method is basically the same as submit(), but it returns text without html tags and other irrelevant data.
submitlinks($URI)
This method returns links.
The above is the complete introduction to PHP Snoopy, I hope it will be helpful to everyone.