how to identify web crawlers of google/yahoo/msn by PHP?

前端 未结 8 1613
清酒与你
清酒与你 2020-12-29 17:51

AFAIK,

$_SERVER[\'REMOTE_HOST\'] should end up with \"google.com\" or \"yahoo.com\".

but is it the most ensuring method?

any other way out?

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-29 17:56

    $_SERVER['HTTP_USER_AGENT']
    
    • Google Bot = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
    • MSN Bot = msnbot-products/1.0 (+http://search.msn.com/msnbot.htm)

    Check various user agent strings here: http://www.user-agents.org/

提交回复
热议问题