Firefox と Safari に従って HAL+Json であるリンクをスクレイピングしようとしていますが、Scrapy が認識しない応答オブジェクトを返しています。
リンクはhttps://catalogue.presto.com.au/です- これはブラウザ内で JSON を表示する Chrome で正常に開きますが、Firefox または Safari を使用しようとすると、代わりにファイルがダウンロードされます。リンクを開くとファイルがダウンロードされるため、Scrapy がスクレイピングしていないのではないかと疑っています。
誰かが似たようなことに遭遇したか、解決策を持っていますか?
シェル経由でアクセスする
端末「scrapy shell https://catalogue.presto.com.au」を使ってウェブサイトにアクセスしようとすると
"2015-03-15 00:15:08+0700 [default] DEBUG: Crawled (200) <GET https://catalogue.presto.com.au>"
次に、(応答) を表示しようとすると、次のエラーが発生します。
>>> view(response)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Library/Python/2.7/site-packages/scrapy/utils/response.py", line 86, in open_in_browser
response.__class__.__name__)
TypeError: Unsupported response type: Response
Scrapy オブジェクトの実行:
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