相关文章推荐
怕老婆的海豚  ·  pycharm显示没有numpy·  2 周前    · 
怕老婆的海豚  ·  Android ...·  1 月前    · 
怕老婆的海豚  ·  el-input ...·  7 月前    · 
私奔的领结  ·  Android ...·  18 小时前    · 
暗恋学妹的投影仪  ·  Android ...·  18 小时前    · 
精明的茶叶  ·  拦截tablayout ...·  18 小时前    · 
傻傻的凳子  ·  TabLayout ...·  18 小时前    · 
温柔的野马  ·  XMLHttpRequest.withCre ...·  18 小时前    · 

1.错误信息

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/scrapy/core/downloader/middleware.py", line 42, in process_request
    defer.returnValue((yield download_func(request=request, spider=spider)))
twisted.web._newclient.ResponseNeverReceived: [<twisted.python.failure.Failure twisted.internet.error.ConnectionDone: Connection was closed cleanly.>]

2.错误原因

这个问题的原因是没有正确设置header头信息,主要指user-agent信息。只要正常设置header头信息就可以运行成功。

3.解决方法

3.1 设置默认的header头信息
DEFAULT_REQUEST_HEADERS = {
  'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  'Accept-Language': 'en',
   "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko)"

打开项目settings.py文件,开启DEFAULT_REQUEST_HEADERS。
注意:

1."User-Agent"这项信息是默认没有的,需要手动添加的。可以通过查看浏览器的请求信息获user-agent。
2.DEFAULT_REQUEST_HEADERS中的配置选项,首字母都是大写的,跟一般的小写不一样。

1.错误信息Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/scrapy/core/downloader/middleware.py", line 42, in process_request d...
记录一个SSL问题: twisted.web._newclient.ResponseNeverReceived: [<twisted.python.failure.Failure OpenSSL.SSL.Error: [('SSL routines', 'ssl23_read', 'ssl handshake failure')]>] 官方文档: DOWNLOADER_CLI...
scrapy 爬虫时报错: <twisted.python.failure.Failure twisted.internet.error.ConnectionLost: Connection to the other side was lost in a non-clean fashion: Connection lost.> <twisted.python.failure.fa...
scrapy 爬虫时报错: <twisted.python.failure.Failure twisted.internet.error.ConnectionLost: Connection to the other side was lost in a non-clean fashion: Connection lost.> <twisted.python.failure.f...
twisted.python.failure.Failure twisted.internet.error.ConnectionLost: Connection to the other side was lost in a non-clean fashion: Connection lost. 解决办法: 打开IE→Internet选项→连接→局域网设置→勾上“自动检测设置” 今天爬取网站突然给我连断开,我楞了好一会,检查了请求头,ip,多线程,我还想是不是我请求太快了。。 这是报错:<twisted.python.failure.Failure twisted.internet.error.ConnectionLost: Connection to th e other side was lost in a non-clean fash...
1.背景说明 新接手的项目,使用miniconda运行,于是按照miniconda官方文档进行安装。因为默认镜像比较慢,所以使用清华大学的镜像,并按照官网的配置。 conda清华镜像源:Anaconda 镜像使用帮助 # 在用户家目录创建conda配置文件 vim ~/.condarc # 粘贴官网的参考配置 channels: - defaults show_channel_urls: true channel_alias: https://mirrors.tuna.tsinghua.ed
conde提示CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/
conde提示CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/ python-numpy-03-创建特定形式数组
 
推荐文章