【问题标题】:twisted.internet.error.ConnectError when run scrapy spider运行scrapy spider时的twisted.internet.error.ConnectError
【发布时间】:2015-07-09 14:18:13
【问题描述】:

我正在使用scrapy运行蜘蛛并得到以下错误:

DEBUG: Retrying http://xixichengyuanlc.fang.com/esf/> (失败2次): 连接时出错: [失败实例: Traceback (failure with no frames): : 连接到对方是以不干净的方式丢失:连接丢失。

我曾经多次成功运行过这个蜘蛛,但我想使用一些用户代理来更快地运行并得到上述错误。起初我认为我的用户代理可能有问题,所以我检查了但仍然无法弄清楚。然后我想再次尝试以前的蜘蛛,但仍然得到同样的错误。

下面是我的settings.py

    # Scrapy settings for soufang project

    SPIDER_MODULES = ['soufang.spiders']
    NEWSPIDER_MODULE = 'soufang.spiders'
    DEFAULT_ITEM_CLASS = 'soufang.items.Community_info'


    ITEM_PIPELINES = ['soufang.pipelines.MySQLStorePipeline']
    #DOWNLOADER_MIDDLEWARES={
    #'scrapy.contrib.downloadermiddleware.useragent.UserAgentMiddleware': None,
    #'soufang.misc.middlewares.CustomUserAgentMiddleware':400}

【问题讨论】:

    标签: python web-scraping scrapy


    【解决方案1】:

    ITEM_PIPELINES 设置不是list,而是dict

    ITEM_PIPELINES = {
        'soufang.pipelines.MySQLStorePipeline': 100
    }
    

    除此之外,我不能确切地说出了什么问题。我没有看到您在设置中设置了USER_AGENT?另外,粘贴完整的日志。

    【讨论】:

    • 感谢劳伦斯。主要问题是我的 ip 被我正在抓取的网站阻止了。目前我遇到了另一个问题[stackoverflow.com/questions/30028585/…。你能提供任何信息吗?非常感谢!
    猜你喜欢
    • 1970-01-01
    • 2020-09-26
    • 2016-03-17
    • 2018-12-20
    • 2013-08-01
    • 2014-03-18
    • 1970-01-01
    • 1970-01-01
    • 2015-10-13
    相关资源
    最近更新 更多