PHP record search engine spider crawl page code

Source: Internet
Author: User
Keywords Web Programming PHP Tutorials
Tags code error_reporting php php tutorial programming return search search engine

PHP Tutorial record search engine Tutorials Spider Crawl page code
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 Spider crawl Record
$searchbot = get_naps tutorial _bot ();
if ($searchbot) {
@mysql tutorial _connect (' localhost ', ' root ') or die (' Can't link Database Tutorial '. mysql_error ());
@mysql_select_db (' spider ') or Die (' cannot select Database '. 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 ' Googlebot ';


        }


      


if (Strpos ($useragent, ' MSNBot ')!== false) {


return ' MSNbot ';


        }


      


if (Strpos ($useragent, ' slurp ')!== false) {


return ' Yahoobot ';


        }





if (Strpos ($useragent, ' Baiduspider ')!== false) {


return ' Baiduspider ';


        }


      


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 my own test (my browser is ie6.0)


return ' MSIE 6.0 ';


  }


return false;


}


?>

</body>
</html>

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.