PHP Picking tool snoopy application [go]

Source: Internet
Author: User
PHP Capture Tool snoopy application [go]
Snoopy is a PHP class that simulates the function of a browser and can retrieve the contents of a Web page and send a form.

Snoopy The PHP version that requires your server to run correctly is above 4 and supports PCRE (Perl Compatible Regular Expressions), basic LAMP service is supported.
Download Snoopy

Some features of Snoopy:

1 fetching the content of a webpage fetch
2 crawling the text content of a Web page (removing HTML tags) fetchtext
3 Crawling Web links, form fetchlinks Fetchform
4 Support Agent Host
5 support basic username/password Verification
6 Support Settings User_agent, Referer (routing), cookies and header content (header file)
7 supports browser redirection and can control redirection depth
8 can expand the link in the Web page into a high-quality URL (default)
9 submit data and get return value
10 support for tracking HTML frames
11 Pass Cookies when redirecting is supported
Requirements PhP4 above can be because PHP is a class without the support of the server does not support curl when the best choice,

Class method:

Fetch ($URI)
———–

This is the method used to crawl the contents of a Web page.
The $URI parameter is the URL address of the crawled Web page.
The results of the fetch are 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 is the demo

Include "Snoopy.class.php";
$snoopy = new Snoopy;

$snoopy->proxy_host = "www.baidu.com";
$snoopy->proxy_port = "8080";

$snoopy->agent = "(compatible; MSIE 4.01; MSN 2.5; AOL 4.0; Windows 98) ";
$snoopy->referer = "http://www.baidu.com/";

$snoopy->cookies["SessionID"] = 238472834723489l;
$snoopy->cookies["FavoriteColor"] = "RED";

$snoopy->rawheaders["Pragma"] = "No-cache";

$snoopy->maxredirs = 2;
$snoopy->offsiteok = false;
$snoopy->expandlinks = false;

$snoopy->user = "Joe";
$snoopy->pass = "Bloe";

if ($snoopy->fetchtext ("http://www.baidu.com"))
{
echo "
". Htmlspecialchars ($snoopy->results)."
\ n ";

}

Else

echo "Error fetching document:". $snoopy->error. " \ n ";

Snoopy Sampling Phpchina Example
Acquisition Phpchina
Set_time_limit (0);
Require_once ("Snoopy.class.php");
$snoopy =new Snoopy ();
Login Forum
$submit _url = "Http://www.phpchina.com/bbs/logging.php?action=login";
$submit _vars["LoginMode"] = "normal";
$submit _vars["Styleid"] = "1";
  • 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.