Record each search spider crawling record php code_PHP tutorial

WBOY
Release: 2016-07-13 10:38:25
Original
955 people have browsed it

Can record Baidu, Google, Bing, Yahoo, Soso, Sogou, Yodao crawling website

The code is as follows:

01 02  //http://www.tongqiong.com 03 function get_naps_bot() 04 { 05 $useragent = strtolower($_SERVER['HTTP_USER_AGENT']); 06   07 if (strpos($useragent, 'googlebot') !== false){ 08 return 'Google'; 09 } 10   11 if (strpos($useragent, 'baiduspider') !== false){ 12 return 'Baidu'; 13 } 14 if (strpos($useragent, 'msnbot') !== false){ 15 return 'Bing'; 16 } 17   18 if (strpos($useragent, 'slurp') !== false){ 19 return 'Yahoo'; 20 } 21   22 if (strpos($useragent, 'sosospider') !== false){ 23 return 'Soso'; 24 } 25   26 if (strpos($useragent, 'sogou spider') !== false){ 27 return 'Sogou'; 28 } 29   30 if (strpos($useragent, 'yodaobot') !== false){ 31 return 'Yodao'; 32 } 33 return false; 34 } 35   36 function nowtime(){ 37 $date=date("Y-m-d.G:i:s"); 38 return $date; 39 } 40   41 $searchbot = get_naps_bot(); 42   43 if ($searchbot) { 44 $tlc_thispage = addslashes($_SERVER['HTTP_USER_AGENT']); 45 $url=$_SERVER['HTTP_REFERER']; 46 $file="www.tongqiong.com.txt"; 47 $time=nowtime(); 48 $data=fopen($file,"a"); 49 fwrite($data,"Time:$time robot:$searchbot URL:$tlc_thispagen"); 50 fclose($data); 51 } 52 //http://www.tongqiong.com 53 ?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/735091.htmlTechArticle可以记录Baidu,Google,Bing,Yahoo,Soso,Sogou,Yodao爬行网站的记录 代码如下: 01?php 02//http://www.tongqiong.com 03functionget_naps_bot() 04{ 05$useragent=strtolower($...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!