PHP Collection Class Snoopy.class.php Introduction and download _php Tutorial

Source: Internet
Author: User
Tags php download php introduction response code

PHP Collection Class Snoopy.class.php Introduction and download


Snoopy is a very powerful PHP class that can be used to perform the task of getting web content and sending forms using this class of mock browsers. The following is a detailed introduction to Snoopy.class.php's features and some common uses.

Official website: http://snoopy.sourceforge.net/(can not open the foreign website of the use of the day line browser)

Download Address: http://sourceforge.net/projects/snoopy/

Download the site: PHP collection library Snoopy.class.php download

Here are some of the features of Snoopy:

1, crawl the content of the page fetch
2, crawl the text content of the webpage (remove HTML tag) fetchtext
3, crawl Web links, form fetchlinks Fetchform
4, support Agent Host
5. Support Basic username/password Verification
6, support set User_agent, Referer (route), Cookies and header content (header file)
7, support browser redirection, and can control the depth of redirection
8, can expand the link in the Web page into a high-quality URL (default)
9. Submit the data and get the return value
10. Support for tracking HTML frame (v0.92 added)
11. Pass cookies when redirecting is supported

Note: Using Snoopy.class.php requirements PHP4 above can be, because it is php a class, no need to expand support, the server does not support curl when the best choice.

Here are some common ways to introduce classes:

Fetch ($URI)

This is the method used to crawl the contents of a Web page. $URI parameter is the URL address of the crawled Web page, and the result of the fetch is stored in the $this->results. If you are crawling a frame, Snoopy will track each frame back into the array and deposit it into the $this->results.

Fetchtext ($URI)

This method is similar to fetch (), except that this method removes HTML tags and other unrelated data, returning only the text content in the page.

Fetchform ($URI)

This method is similar to fetch (), except that this method removes HTML tags and other unrelated data and returns only the form content (form) in the Web page.

Fetchlinks ($URI)

This method is similar to fetch (), except that this method removes HTML tags and other unrelated data and only returns links to the Web page. By default, relative links are automatically completed and converted to full URLs.

Submit ($URI, $formvars)

This method sends a confirmation form to the link address specified by the. $formvars is an array of stored form parameters.

Submittext ($URI, $formvars)

This method is similar to submit (), the only difference is that this method will remove the HTML tags and other unrelated data, only return to the page after landing text content.

Submitlinks ($URI)

This method is similar to submit (), the only difference is that this method will remove the HTML tags and other unrelated data, only return the link in the Web page. By default, relative links are automatically completed and converted to full URLs.

Class Properties: (default value in parentheses)

$host a connected host
$port Connected Ports
$proxy proxy host used by _host, if any
$proxy the proxy host port used by the _port, if any
$agent User Agent Spoofing (Snoopy v0.1)
$referer Route information, if any
$cookies cookies, if any
$rawheaders Other header information, if any
$maxredirs maximum redirects, 0 = not allowed (5)
$offsiteok whether or not to allow redirects off-site. (true)
$expandlinks whether to complete the link with full address (true)
$user authenticated user name, if any
$pass authenticated user name, if any
$accept http Accept type (image/gif, Image/x-xbitmap, Image/jpeg, Image/pjpeg, */*)
$error where to error, if any.
$response _code Response code returned from the server
$headers header information returned from the server
$maxlength Longest return data length
$read _timeout Read operation timeout (requires PHP 4 Beta 4+) set to 0 for no timeout
$timed _out If a read operation times out, this property returns True (Requires PHP 4 Beta 4+)
Maximum number of frames $maxframes allowed to track
$status the state of the crawled HTTP
$temp Temporary file directory (/tmp) that the _dir Web server can write to
$curl _path Curl Binary directory, if no curl binary is set to False

Here are a few common examples of usage:

(1) Grab the text on the first page of the PHP Programmer's note site

 
  Fetchtext ("http://www.phpernote.com"); Echo $snoopy->results;

(2) Crawl the PHP Programmer's note site home page of all links

 
  Fetchlinks ("http://www.phpernote.com");p Rint_r ($snoopy->results);

(3) Access to the landing Renren what fields to send, the destination address is what

 
  Fetchform ("http://www.renren.com/PLogin.do");p Rint_r ($snoopy->results);

(4) Analog landing Renren

 
  Referer= ' http://www.renren.com/'; $snoopy->agent= "mozilla/5.0 (Windows NT 6.1; rv:22.0) gecko/20100101 firefox/ 22.0 "; $submit _vars[' email '] = ' login account '; $submit _vars[' password '] = ' login password '; $url = ' http://www.renren.com/PLogin.do ';// Login data submitted URL address $snoopy->submit ($url, $submit _vars); $snoopy->fetch ("http://www.renren.com/");//The page data you want to get echo $ Snoopy->results;//www.phpernote.com

Articles you may be interested in

    • PHP uses curl to implement multi-threaded classes, php curl multithreading download pictures
    • PHP Snoopy Collection Class Introduction
    • PHP uses Curl Functions to crawl Web pages and download files in multiple threads
    • PHP implementation of the file batch compression package download
    • Powerful PHP Image processing class (watermark, transparency, zoom, sharpen, rotate, flip, cut, invert)
    • Use PHP function memory_get_usage to get the current PHP memory consumption to achieve program performance optimization
    • PHP limit file Download speed function
    • How to remove the index.php string from the URL of the website CodeIgniter developed

http://www.bkjia.com/PHPjc/930520.html www.bkjia.com true http://www.bkjia.com/PHPjc/930520.html techarticle PHP Collection Class Snoopy.class.php Introduction and Download Snoopy is a very powerful PHP class that can be used to perform the task of getting web content and sending forms using this class of mock browsers. Here is the ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.