PHP code for retrieving crawling records of search Spider _ PHP Tutorial

Source: Internet
Author: User
The code written by PHP to obtain crawling records of search spider. The following is a search engine that uses php to obtain crawling records of various search Spider. the supported search engines can record the following records: Baidu, Google, Bing, Yahoo, Soso, Sogou, and Yodao crawling websites! Php code. The following is a code written in php to obtain crawling records of search spider.
The following search engines are supported:
Record the crawling websites of Baidu, Google, Bing, Yahoo, Soso, Sogou, and Yodao!
The php code is as follows:

The code is as follows:


Function get_naps_bot ()
{
$ Useragent = strtolower ($ _ SERVER ['http _ USER_AGENT ']);
If (strpos ($ useragent, 'googlebot ')! = False ){
Return 'Google ';
}
If (strpos ($ useragent, 'baidider Ider ')! = False ){
Return 'baidu ';
}
If (strpos ($ useragent, 'msnbot ')! = False ){
Return 'bin ';
}
If (strpos ($ useragent, 'slurp ')! = False ){
Return 'Yahoo ';
}
If (strpos ($ useragent, 'sosospider ')! = False ){
Return 'sososo ';
}
If (strpos ($ useragent, 'sogou spider ')! = False ){
Return 'sogou ';
}
If (strpos ($ useragent, 'yodaobot ')! = False ){
Return 'yodao ';
}
Return false;
}
Function nowtime (){
$ Date = date ("Y-m-d.G: I: s ");
Return $ date;
}
$ Searchbot = get_naps_bot ();
If ($ searchbot ){
$ Tlc_thispage = addslashes ($ _ SERVER ['http _ USER_AGENT ']);
$ Url = $ _ SERVER ['http _ referer'];
$ File = "www.jb51.net.txt ";
$ Time = nowtime ();
$ Data = fopen ($ file, "");
Fwrite ($ data, "Time: $ time robot: $ searchbot URL: $ tlc_thispage \ n ");
Fclose ($ data );
}
// Collect http://www.jb51.net
?>

Supports the following search engines to record the crawler website records of Baidu, Google, Bing, Yahoo, Soso, Sogou, and Yodao! Php code...

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.