admin管理员组文章数量:1560416
/**
* 判断是否为搜索引擎蜘蛛
*
* @access public
* @return string
*/
function is_spider($record = true)
{
static $spider = NULL;
if ($spider !== NULL)
{
return $spider;
}
if (empty($_SERVER['HTTP_USER_AGENT']))
{
$spider = '';
return '';
}
$searchengine_bot = array(
'googlebot',
'mediapartners-google',
'baiduspider+',
'msnbot',
'yodaobot',
'yahoo! slurp;',
'yahoo! slurp china;',
'iaskspider',
'sogou web spider',
'sogou push spider'
);
$searchengine_name = array(
'GOOGLE',
'GOOGLE ADSENSE',
'BAIDU',
'MSN',
'YODAO',
'YAHOO',
'Yahoo China',
'IASK',
'SOGOU',
'SOGOU'
);
$spider = strtolower($_SERVER['HTTP_USER_AGENT']);
foreach ($searchengine_bot AS $key => $value)
{
if (strpos($spider, $value) !== false)
{
$spider = $searchengine_name[$key];
if ($record === true)
{
//记录引擎抓取
}
return $spider;
}
}
$spider = '';
return '';
}
版权声明:本文标题:php判断搜索引擎是否蜘蛛 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1727438445a1114715.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论