栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Failure while parsing robots.txt. File either contains garbage or is in an encoding other than UTF-8

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Failure while parsing robots.txt. File either contains garbage or is in an encoding other than UTF-8

在使用scrapy爬取图片的时候返回了一个这样的错误

Failure while parsing robots.txt. File either contains garbage or is
in an encoding other than UTF-8, treating it as an empty file

这里先看一下robot.txt是什么?
settings.py里面有一条:

ROBOTSTXT_OBEY = True

就是表示要遵守robots.txt 的规则
1)robots.txt 是遵循 Robot协议 的一个文件,它保存在网站的服务器中,它的作用是,告诉搜索引擎爬虫,本网站哪些目录下的网页不希望你进行爬取收录。
2)在Scrapy启动后,会在第一时间访问网站的 robots.txt 文件,然后决定该网站的爬取范围。
3)但是在某些情况下我们想要获取的内容恰恰是被 robots.txt 所禁止访问的。此时我们就要将此配置项设置为 False ,拒绝遵守 Robot协议 。
看完这里就知道了,修改代码:

ROBOTSTXT_OBEY = False

报错就没有了,然后继续往下进行!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/488702.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号