【问题标题】:Connection to other side was lost in a non-clean fashion与另一端的连接以不干净的方式丢失
【发布时间】:2013-09-14 06:46:24
【问题描述】:
from scrapy.spider import BaseSpider

class dmozSpider(BaseSpider):
    name = "dmoz"
    allowed_domains = ["dmoz.org"]
    start_urls = [
        "http://www.dmoz.org/Computers/Programming/Languages/Python/Books/",
        "http://www.dmoz.org/Computers/Programming/Languages/Python/Resources/"
    ]

    def parse(self, response):
        filename = response.url.split("/")[-2]
        open(filename, 'wb').write(response.body)

然后我运行“scrapy crawl dmoz” 然后我得到了这个错误:

2013-09-14 13:20:56+0700 [dmoz] 调试:重试 http://www.dmoz.org/Computers/Programming/Languages/Python/Resources/> (失败 1 次):与另一端的连接在非清洁中丢失 时尚。

有谁知道如何解决这个问题?

【问题讨论】:

  • 听起来像是网络服务器或连接问题。你在这里无能为力。请稍后再试。

标签: python scrapy


【解决方案1】:

您需要检查您的互联网连接,或者如果您使用代理,请设置您的环境变量以进行代理身份验证。

在 Windows 中,请尝试以下步骤:

  1. Win+R type 'systempropertiesadvanced'(不带 报价)
  2. 点击“环境变量...”按钮
  3. 添加 2 个新变量(用户/系统变量都可以):
姓名 |价值 ------------+-------------------------------- HTTP_PROXY | http://用户名:密码@主机:端口 HTTPS_PROXY | https://用户名:密码@主机:端口

替代方式:setting-proxy-env

【讨论】:

  • 感谢您的回答!这个对我有用!我没有注意到我的笔记本电脑使用代理连接到互联网!
  • linux 用户呢?
  • @AlbertoLópezPérez 在linux中设置环境变量你可以使用export HTTP_PROXY=http://username:password@host:port
猜你喜欢
  • 2017-07-21
  • 2018-06-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多