Web Crawler - Ignore Robots.txt file?

2019-03-18 19:03发布

Some servers have a robots.txt file in order to stop web crawlers from crawling through their websites. Is there a way to make a web crawler ignore the robots.txt file? I am using Mechanize for python.

2条回答
该账号已被封号
2楼-- · 2019-03-18 19:28

This looks like what you need:

from mechanize import Browser
br = Browser()

# Ignore robots.txt
br.set_handle_robots( False )

but you know what you're doing…

查看更多
Bombasti
3楼-- · 2019-03-18 19:48

The documentation for mechanize has this sample code:

br = mechanize.Browser()
....
# Ignore robots.txt.  Do not do this without thought and consideration.
br.set_handle_robots(False)

That does exactly what you want.

查看更多
登录 后发表回答