根据Firefox和Safari的说法,我试图获取一个HAL+Json的链接,它返回了一个Scrapy无法识别的响应对象。在
链接是https://catalogue.presto.com.au/-这在Chrome中打开很好,在浏览器中显示JSON,但是如果我尝试使用Firefox或Safari,它会下载文件。我怀疑Scrapy打开链接时下载的文件,所以它不刮它。在
有没有人遇到过类似的情况或有解决办法?在
通过Shell访问
当我试图使用终端“scrapy shellhttps://catalogue.presto.com.au”访问网站时
"2015-03-15 00:15:08+0700 [default] DEBUG: Crawled (200) <GET https://catalogue.presto.com.au>"
然后我尝试查看(响应)并得到以下错误:
^{pr2}$运行报废对象:
def parse(self, response):
print response.__class__
open_in_browser(response)
2015-03-15 00:23:05+0700 [prestotv2] DEBUG: Crawled (200) <GET
class 'scrapy.http.response.Response' (referer: None) #this line is from "print response.__class__
2015-03-15 00:23:05+0700 [prestotv2] ERROR: Spider error processing <GET https://catalogue.presto.com.au/>
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/twisted/internet/base.py", line 1201, in mainLoop
self.runUntilCurrent()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/twisted/internet/base.py", line 824, in runUntilCurrent
call.func(*call.args, **call.kw)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/twisted/internet/defer.py", line 382, in callback
self._startRunCallbacks(result)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/twisted/internet/defer.py", line 490, in _startRunCallbacks
self._runCallbacks()
--- <exception caught here> ---
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/twisted/internet/defer.py", line 577, in _runCallbacks
current.result = callback(current.result, *args, **kw)
File "/Users/nathansu/Documents/Development/Whutstream/scraping/Presto/presto/spiders/TvSpider.py", line 38, in parse
open_in_browser(response)
File "/Library/Python/2.7/site-packages/scrapy/utils/response.py", line 86, in open_in_browser
response.__class__.__name__)
exceptions.TypeError: Unsupported response type: Response
这是因为响应} (或使用here列出的库之一)加载它:
Content-Type
等于application/hal+json
。如果要解析它,请通过^{相关问题 更多 >
编程相关推荐