如何禁止不遵守robots.txt的机器人?

时间:2014-10-18 19:11:38

标签: google-app-engine python-2.7 jinja2 robots.txt webapp2

我最近更改了robots.txt以禁止机器人进行昂贵的搜索API查询。除了/q?...这是一个搜索API查询且价格昂贵之外,他们现在可以使用其他所有页面。

User-agent: *
Disallow: /q?

Sitemap: /sitemap.xml.gz

现在我仍然在我的日志中获取机器人。它是google还是只是“googlebot兼容”?我如何完全禁止机器人/ q?

2014-10-18 21:04:23.474 /q?query=category%3D5030%20and%20cityID%3D4698187&o=4 200 261ms 7kb Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) module=default version=disallow
66.249.79.28 - - [18/Oct/2014:12:04:23 -0700] "GET /q?query=category%3D5030%20and%20cityID%3D4698187&o=4 HTTP/1.1" 200 8005 - "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"  ms=261 cpu_ms=108 cpm_usd=0.050895 app_engine_release=1.9.13 instance=00c61b117cdfd20321977d865dd08cef54e2fa

我是否可以根据我的请求处理程序中的http标头或我的dos.yaml将特定机器人列入黑名单,如果robots.txt无法执行此操作?当我运行此寻找比赛时,过去2小时有50场比赛:

path:/q.* useragent:.*Googlebot.*

日志行看起来像这样,看起来像googlebot:

2014-10-19 00:37:34.449 /q?query=category%3D1030%20and%20cityID%3D4752198&o=18 200 138ms 7kb Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) module=default version=disallow 66.249.79.102 - - [18/Oct/2014:15:37:34 -0700] "GET /q?query=category%3D1030%20and%20cityID%3D4752198&o=18 HTTP/1.1" 200 7965 - "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" "www.classifiedsmarket.appspot.com" ms=138 cpu_ms=64 cpm_usd=0.050890 app_engine_release=1.9.13 instance=00c61b117c781458f46764c359368330c7d7fdc4

1 个答案:

答案 0 :(得分:1)

是的,每位访问者/机器人都可以声称Googlebot/2.1(通过更改User-Agent header)。

您可以使用反向DNS查找verify that it was the real Googlebot

根据您日志中的IP,它似乎是真正的机器人。你的robots.txt也是正确的。因此,在Google识别出新规则之前应该只是时间问题,之后所有请求都应该停止。

不尊重robots.txt的机器人当然可以阻止访问资源,但是(根据您识别机器人的标准),这也有可能阻止人类访问者。