PHP collection class Snoopy. class. php

Source: Internet
Author: User
PHP collection class Snoopy. class. php
SnoopyIt is a php collection class used to simulate a browser to obtain webpage content and send forms.

The following are some Snoopy features:

Easy to crawl webpage content

Easy to crawl page text (remove html tags)

Easy to crawl links on webpages

Supports proxy crawling

Supports basic user name and password authentication

Supports setting user-agent, referer, cookies, and header content

Support browser redirection and control steering depth

Converting links on pages into high-quality links

Easy to submit data and obtain returned values

Tracking HTML framework

Supports sending Cookies during redirection

Snoopy class, method:

Fetch ($ URI)

The method used to capture the content of a webpage. $ URI is the URL of the webpage to be crawled. The captured results are stored in $ this-> results. If you are capturing a framework, Snoopy will track each frame and store it in an array, and then save it to $ this-> results.

Fetchtext ($ URI)

This method is similar to fetch (). The only difference is that this method will remove HTML tags and other irrelevant data and only return the text content in the webpage.

Fetchform ($ URI)

This method is similar to fetch (). The only difference is that this method will remove the HTML tag and other irrelevant data and only return the form content (form) in the webpage ).

Fetchlinks ($ URI)

This method is similar to fetch (). The only difference is that this method will remove HTML tags and other irrelevant data and only return links in the webpage ). By default, the relative link is automatically completed and converted to a complete URL.

Submit ($ URI, $ formvars)

This method sends a confirmation form to the URL specified by $ URL. $ Formvars is an array that stores form parameters.

Submittext ($ URI, $ formvars)

This method is similar to submit (). The only difference is that this method will remove HTML tags and other irrelevant data and only return the text content on the webpage after login.

Submitlinks ($ URI)

This method is similar to submit (). The only difference is that this method will remove HTML tags and other irrelevant data and only return links in the webpage ). By default, the relative link is automatically completed and converted to a complete URL.

Class property: (the default value is in brackets)

$ Host connected host

$ Port connection port

$ Proxy_host: the proxy host used, if any

$ Proxy_port indicates the proxy Host Port used. If yes

$ Agent User proxy disguise (Snoopy v0.1)

$ Referer information, if any

$ Cookies, if any

$ Rawheaders other header information, if any

$ Maxredirs maximum redirect times, 0 = not allowed (5)

$ Offsiteok whether or not to allow redirects off-site. (true)

$ Expandlinks: whether to add all links to the full address (true)

$ User authentication username, if any

$ Pass authentication username, if any

$ Accept http accept type (image/gif, image/x-xbitmap, image/jpeg, image/pjpeg ,*/*)

$ Error: where is the error reported? if Yes

$ Response_code response code returned from the server

$ Headers header information returned from the server

$ Maxlength: maximum length of returned data

$ Read_timeout read operation timeout (requires PHP 4 Beta 4 +) is set to 0 to no timeout

$ Timed_out if a read operation times out, this attribute returns true (requires PHP 4 Beta 4 +)

$ Maxframes maximum number of frames that can be tracked

$ Status indicates the http status captured.

$ Temp_dir temporary file directory (/tmp) that can be written by the webpage server)

$ Curl_path cURL binary Directory. If no cURL binary is available, set it to false.

Snoopy official website: http://sourceforge.net/projects/snoopy/

I hope this article will be helpful to the majority of php developers. thank you for reading this article. MorePhp technical problemsWelcome to group discussion:256271784, Verification code:CxyIf you do not write the verification code, it will not pass yo ~

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.