网页爬虫 - 忽略 Robots.txt 文件?
有些服务器会放一个叫做robots.txt的文件,目的是为了阻止网络爬虫访问他们的网站。请问有没有办法让网络爬虫忽略这个robots.txt文件呢?我在用Python的Mechanize库。
2 个回答
9
这个链接看起来正是你需要的内容:
from mechanize import Browser
br = Browser()
# Ignore robots.txt
br.set_handle_robots( False )
不过你应该知道自己在做什么……
30
mechanize的文档里有一段示例代码:
br = mechanize.Browser()
....
# Ignore robots.txt. Do not do this without thought and consideration.
br.set_handle_robots(False)
这段代码正好实现了你想要的功能。