This article describes the PHP record search engine spiders visit the site footprint method. Share to everyone for your reference. The specific analysis is as follows:
Search engine Spider Visit Web site is through the remote crawl page, we can not use the JS code to obtain the agent information of the spider, but we may through the image tag, so we can get the spider agent data, through the agent data analysis, you can determine the type of spider , gender and other factors, we can be counted through the database or the text to record.
<?php/************************* NAPS--Network article Publish system*------------------------------------------ ----* bot.php*-------------------* begin:2004-08-15*************************//************************** Thi S program was free software; Can redistribute it and/or modify* it under the terms of the GNU general public License as published by* Ftware Foundation; Either version 2 of the license.*************************//************************** NAPs product is free software. You may and must reproduce, modify and distribute NAPs products in accordance with the provisions of the GNU GPL-GNU general Public License. Any derivative distributions based on NAPs products do not have to go through a floating license. /error_reporting (E_all & ~e_notice); function Get_naps_bot () {$useragent = Strtolower ($_ server[' http_user_agent '); if (Strpos ($useragent, ' Googlebot ')!== false) {return ' Googlebot ';} if (Strpos ($useragent, ' MSNBot ')!== false) {Retur n ' msnbot '; } if (Strpos ($useragent, ' slurp ')!== false) {return ' Yahoobot ';} if (Strpos ($useragent, ' Baiduspider ')!== false) {RET Urn ' BaiduspiDer '; } if (Strpos ($useragent, ' Sohu-search ')!== false) {return ' Sohubot ';} if (Strpos ($useragent, ' Lycos ')!== false) {Retu RN ' Lycos '; } if (Strpos ($useragent, ' Robozilla ')!== false) {return ' Robozilla ';} return false;} $TLC _thispage = addslashes ($_server[' http_user_agent '));//Add Spider's fetch record $searchbot = Get_naps_bot (); if ($searchbot) {$DB _ Naps->query ("UPDATE naps_stats_bot SET botcount=botcount+1, Botlast=now (), botlasturl= ' $TLC _thispage ' WHERE Botname= ' $searchbot ');}? >
I hope this article is helpful to everyone's PHP programming.
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.