import robotparser rp = robotparser.RobotFileParser() rp.set_url('url/robot.txt') rp.read()
user_agent = 'Spider' rp.can_fetch(user_agent, url)
Boolean变量可以检测代理是否可以爬取
爬虫系列8解析robots.txt
最新推荐文章于 2024-03-02 11:40:49 发布
import robotparser rp = robotparser.RobotFileParser() rp.set_url('url/robot.txt') rp.read()
user_agent = 'Spider' rp.can_fetch(user_agent, url)
Boolean变量可以检测代理是否可以爬取