请问如何用PHP代码来判断搜索引擎蜘蛛来路? 请问如何用PHP代码来判断搜索引擎蜘蛛来路,作出判断后执行其它代码。比如:被判断出是百度蜘蛛来访问时,网页执行一种代码,正常用户访问或者其它引擎蜘蛛来访问时,网页执行另一种代码。麻烦高手赐教,偶是PHP新手,最好能得到详细一些,如实例代码的答案,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?phpfunction get_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'; } return false;}?> 根据$_SERVER['HTTP_REFERER']判断来路根据$_SERVER['HTTP_USER_AGENT']来识别访问者身份比如Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322, Baidu-Transcoder/1.0.6.0, gate.baidu.com)msnbot/1.1 (+http://search.msn.com/msnbot.htm)Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)……你是不是想以这种方式,加入无关关键词,搜索作弊?可能会被惩罚的,慎用 主要使用user_agent来判断的,有网站收录了很多的user_agent用作匹配http://user-agent-string.info/download/UASparser-for-PHP 搜索作弊! 沒有必要 完全可以SEO 來搞定排名 崇明农家乐旅游http://www.chongmingu8.com 谢谢大家帮忙,已经结贴,请接分哦!还想请大家帮我一下,有关MYSQL子查询的问题,打开以下地址:http://topic.csdn.net/u/20100720/22/6049d9a2-ea75-4f57-a5a7-507e781dfb2f.html?45731 常见的PHP安全漏洞-跨站、注入和文件包含 求助php单页面多table刷新问题. 问一下有关time()方法的问题 一段关于记录访问量的 求助:增加一段播放音乐的代码!!!!!!!!! my.my.net与my.net之间互访是不是跨域? MYSQL的查询速度问题,一起探讨,对大家都有好处! 高分求请教:用php制作二级关联菜单,且能从数据库中取记录. PHP输出缓存头信息问题 为什么这种socket程序会无限执行sql语句而不被挂起? isset($_GET['login']) 刚刚接触PHP,菜鸟,请教环境配置的问题。。。
function get_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';
}
return false;
}
?>
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322, Baidu-Transcoder/1.0.6.0, gate.baidu.com)msnbot/1.1 (+http://search.msn.com/msnbot.htm)Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
……你是不是想以这种方式,加入无关关键词,搜索作弊?可能会被惩罚的,慎用
http://user-agent-string.info/download/UASparser-for-PHP
http://topic.csdn.net/u/20100720/22/6049d9a2-ea75-4f57-a5a7-507e781dfb2f.html?45731