当前位置:才华咖 > 互联网计算机 > 计算机 > php语言 > PHP写的获取各搜索蜘蛛爬行记录代码
手机版

PHP写的获取各搜索蜘蛛爬行记录代码

来源:才华咖 阅读:1.74W 次

网站百度蜘蛛等搜索引擎爬虫是否了网站 来抓取文章,一般站长不知道怎么搞用工具查询,也可以查看空间里的`日志,但是空间里的日志的记录全是代码你不知道那个是搜索引擎爬虫的来路。那么下面分享一款用php写的获取各搜索蜘蛛爬行记录代码。

PHP写的获取各搜索蜘蛛爬行记录代码

  支持搜索引擎如下

可以记录Baidu,Google,Bing,Yahoo,Soso,Sogou,Yodao爬行网站的记录!

php代码如下

  复制代码 代码如下:

<?php

function get_naps_bot()

{

$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);

if (strpos($useragent, 'googlebot') !== false){

return 'Google';

}

if (strpos($useragent, 'baiduspider') !== false){

return 'Baidu';

}

if (strpos($useragent, 'msnbot') !== false){

return 'Bing';

}

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

return 'Yahoo';

}

if (strpos($useragent, 'sosospider') !== false){

return 'Soso';

}

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="";

$time=nowtime();

$data=fopen($file,"a");

fwrite($data,"Time:$time robot:$searchbot URL:$tlc_thispagen");

fclose($data);

}

//收集整理

?>

本文链接:https://www.caihuaka.com/jsjzs/php/8qm2m9.html

Copyright © 2024. 才华咖 All right reserved. 浙ICP备20120231号-3

文字美图素材,版权属于原作者。部分文章内容由网友提供推送时因种种原因未能与原作者联系上,若涉及版权问题,敬请原作者联系我们,立即处理。