【问题标题】:Scrapy, Scrapinghub and Google Cloud Storage: Keyerror 'gs' while running the spider on scrapinghubScrapy、Scrapinghub 和 Google Cloud Storage:在 scrapinghub 上运行爬虫时出现 Keyerror 'gs'
【发布时间】:2018-02-22 10:35:47
【问题描述】:

我正在使用 Python 3 开发一个 scrapy 项目,并且蜘蛛被部署到 scrapinghub。我还使用 Google Cloud Storage 来存储官方文档here 中提到的抓取文件。

当我在本地运行蜘蛛时,它运行得非常好,并且蜘蛛被部署到 scrapinghub 时没有任何错误。我使用 scrapy:1.4-py3 作为 scrapinghub 的堆栈。在上面运行蜘蛛时,我收到以下错误:

    Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/twisted/internet/defer.py", line 1386, in _inlineCallbacks
    result = g.send(result)
  File "/usr/local/lib/python3.6/site-packages/scrapy/crawler.py", line 77, in crawl
    self.engine = self._create_engine()
  File "/usr/local/lib/python3.6/site-packages/scrapy/crawler.py", line 102, in _create_engine
    return ExecutionEngine(self, lambda _: self.stop())
  File "/usr/local/lib/python3.6/site-packages/scrapy/core/engine.py", line 70, in __init__
    self.scraper = Scraper(crawler)
  File "/usr/local/lib/python3.6/site-packages/scrapy/core/scraper.py", line 71, in __init__
    self.itemproc = itemproc_cls.from_crawler(crawler)
  File "/usr/local/lib/python3.6/site-packages/scrapy/middleware.py", line 58, in from_crawler
    return cls.from_settings(crawler.settings, crawler)
  File "/usr/local/lib/python3.6/site-packages/scrapy/middleware.py", line 36, in from_settings
    mw = mwcls.from_crawler(crawler)
  File "/usr/local/lib/python3.6/site-packages/scrapy/pipelines/media.py", line 68, in from_crawler
    pipe = cls.from_settings(crawler.settings)
  File "/usr/local/lib/python3.6/site-packages/scrapy/pipelines/images.py", line 95, in from_settings
    return cls(store_uri, settings=settings)
  File "/usr/local/lib/python3.6/site-packages/scrapy/pipelines/images.py", line 52, in __init__
    download_func=download_func)
  File "/usr/local/lib/python3.6/site-packages/scrapy/pipelines/files.py", line 234, in __init__
    self.store = self._get_store(store_uri)
  File "/usr/local/lib/python3.6/site-packages/scrapy/pipelines/files.py", line 269, in _get_store
    store_cls = self.STORE_SCHEMES[scheme]
KeyError: 'gs'

PS: 'gs' 用于存放文件的路径

'IMAGES_STORE':'gs://<bucket-name>/'

我已经研究过这个错误,但没有任何解决方案。任何帮助都会有很大的帮助。

【问题讨论】:

    标签: python-3.x scrapy google-cloud-platform google-cloud-storage scrapinghub


    【解决方案1】:

    Google Cloud Storage 支持是 Scrapy 1.5 中的一项新功能,因此您需要在 Scrapy Cloud 中使用 scrapy:1.5-py3 堆栈。

    【讨论】:

      猜你喜欢
      • 2019-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-09
      • 2019-02-24
      • 2019-06-24
      • 2013-04-14
      相关资源
      最近更新 更多