可过落地页检测以及屏蔽快照抓取广告
function siyuan_crawler(){ $key= $_SERVER["HTTP_USER_AGENT"]; if(strpos($key,'google')!== false||strpos($key,'baidu')!==false){ return true; }else{ return false; } }
或者
function siyuan_crawler() { $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); $spiders = array( 'Googlebot', // Google蜘蛛 'Baiduspider', //百度蜘蛛 '360Spider',//360蜘蛛 'Sogou News Spider',//搜狗蜘蛛 'bingbot',//必应蜘蛛 'Sosospider',//搜搜蜘蛛 ); if(!empty($userAgent)){ foreach ($spiders as $spider) { $spider = strtolower($spider); if (strpos($userAgent, $spider) !== false) { return true; } } } return false; }
{if !siyuan_crawler()}
这里是广告代码 蜘蛛不可见
{/if}