【问题标题】:Identify visit from robot [duplicate]识别来自机器人的访问[重复]
【发布时间】:2014-01-19 18:55:48
【问题描述】:

在我的站点中,每当有访问时,我都会发送一个 cookie,然后将数据保存在 db(数据、IP、引用者、平台)中。 cookie 用于避免记录相同的用户访问。 我的问题很简单:如何识别来自机器人的访问?有可能吗?

【问题讨论】:

    标签: php ip web-crawler referer


    【解决方案1】:

    阅读User Agent

    if( preg_match('/robot|spider|crawler|curl|^$/i', $_SERVER['HTTP_USER_AGENT'])) )
    { 
        echo 'Is bot or spider or crawler or curl or not human';
    }
    else
    {
        echo 'Is human';
    }
    

    您可以在此处找到机器人提供的大约 300 个常见用户代理的列表:http://www.robotstxt.org/db.html

    【讨论】:

      猜你喜欢
      • 2013-12-21
      • 2020-03-07
      • 2016-11-05
      • 2019-12-30
      • 2012-08-06
      • 1970-01-01
      • 2015-08-13
      • 2020-02-19
      • 2012-07-01
      相关资源
      最近更新 更多