Php record search engine spider capture Page code-PHP source code

Source: Internet
Author: User
Tags mysql tutorial
Ec (2); error_reporting (E_ALL & amp ;~ E_NOTICE); $ tlc_thispageaddslashes ($ _ SERVER [HTTP_REFERER]. $ _ SERVER [PHP_SELF]); * ($ _ SERVER [HTTP_HOST]. $ _ SERVER [PHP_SELF]); ($ _ SERVER [HTTP_USER_AGENT script ec (2); script

Error_reporting (E_ALL &~ E_NOTICE );

$ Tlc_thispage = addslashes ($ _ SERVER ['HTTP _ referer']. $ _ SERVER ['php _ SELF ']);/* ($ _ SERVER ['HTTP _ host']. $ _ SERVER ['php _ SELF ']); ($ _ SERVER ['HTTP _ USER_AGENT']); */
// Add a crawler record
$ Searchbot = get_naps tutorial _ bot ();
If ($ searchbot ){
@ Mysql tutorial _ connect ('localhost', 'root') or die ('cannot link to database example'. mysql_error ());
@ Mysql_select_db ('spider ') or die ('database not selectable'. mysql_error ());

Mysql_query ("UPDATE bot SET botcount = botcount + 1, botlast = NOW (), botlasturl = '$ tlc_thispage' WHERE botname = '$ searchbot '");
}
Mysql_close ();


Function get_naps_bot ()
{
$ Useragent = strtolower ($ _ SERVER ['HTTP _ USER_AGENT ']);

If (strpos ($ useragent, 'googlebot ')! = False ){
Return 'bot bot ';
}

If (strpos ($ useragent, 'msnbot ')! = False ){
Return 'msnbot ';
}

If (strpos ($ useragent, 'slurp ')! = False ){
Return 'yahoobot ';
}

If (strpos ($ useragent, 'baidider ider ')! = False ){
Return 'baidider ider ';
}

If (strpos ($ useragent, 'sohu-search ')! = False ){
Return 'sohubot ';
}

If (strpos ($ useragent, 'lycos ')! = False ){
Return 'lycos ';
}

If (strpos ($ useragent, 'robozilla ')! = False ){
Return 'robozilla ';
}
If (strpos ($ useragent, 'msie 6.0 ')! = False) {// This is for my own test (my browser is ie6.0)
Return 'msie 6.0 ';
}
Return false;
}


?>


Related Article

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.