php教程記錄搜尋引擎教程蜘蛛抓取頁面代碼
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']);*/
添加蜘蛛的抓取記錄
$searchbot = get_naps教程_bot();
if ($searchbot) {
@mysql教程_connect('localhost','root') or die('不能連結資料庫教程'.mysql_error());
@mysql_select_db('spider') or die('不能選擇資料庫'.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){ //這條是我自己測試用的(我的瀏覽器就是ie6.0)
return 'MSIE 6.0';
}
return false;
}
?>
</body>
</html>