【问题标题】:Scrapy shell cannot find response objectScrapy shell 找不到响应对象
【发布时间】:2020-06-16 20:45:37
【问题描述】:

我是 Scrapy 的新手,并试图按照本教程 (https://www.pythongasm.com/introduction-to-scrapy/) 来了解它。

我使用 fetch 命令抓取了这个页面 (https://newyork.craigslist.org/d/real-estate/search/rea),但是当我输入 view(response) 时出现以下错误:

>>> view(response)
Start : this command could not be executed due to error: the system could not find the specified file.
In line:1 character:1
+ Start "file:///tmp/tmppjvn5nzf.html"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand

当我检查file:///tmp/tmppjvn5nzf.html 时,我看到页面中的信息被抓取,但没有分配给响应对象。

你知道我该如何解决这个问题吗?

【问题讨论】:

    标签: scrapy scrapy-shell


    【解决方案1】:

    你应该尝试运行命令

    scrapy shell https://newyork.craigslist.org/d/real-estate/search/rea
    

    这应该给你一个:

    2020-06-17 13:05:02 [scrapy.core.engine] DEBUG: Crawled (200) <GET https://newyork.craigslist.org/d/real-estate/search/rea> (referer: None)
    

    终端中的消息。然后要测试它是否有效,请键入以下内容:

    response.css('.result-hood::text').getall()
    

    获取房屋列表中的所有位置。如果您有任何问题,您应该能够非常简单地使用它,我建议您观看来自https://www.youtube.com/user/eupendras 的 YouTube 教程。它们是很好解释的教程,带你慢慢学习 Scrapy。

    【讨论】:

      猜你喜欢
      • 2016-02-07
      • 1970-01-01
      • 2017-10-13
      • 1970-01-01
      • 1970-01-01
      • 2017-01-11
      • 2019-07-31
      • 1970-01-01
      • 2013-11-02
      相关资源
      最近更新 更多