1
は、私は、端末でscrap.Requestオブジェクトをシェルで処理する方法はありますか?ターミナルで
import scrapy
class QuotesSpider(scrapy.Spider):
name = "quotes"
start_urls = ['http://quotes.toscrape.com/page/1/']
spiders
フォルダに以下のクモを作成し、私はこのすべてが同様に正常に動作
scrapy shell 'http://quotes.toscrape.com/page/1/'
を走った
scrapy startproject tutorial
を走りました私が開くPythonシェル
>>> response
<200 http://quotes.toscrape.com/page/1/>
は今、私はnext_page
へのリンクに基づいて、シェルで新しいResponse
オブジェクトを取得したいと思い
>>> next_page = response.css('li.next a::attr(href)').extract_first()
>>> next_page
'/page/2/'
>>> response.follow(next_page)
<GET http://quotes.toscrape.com/page/2/>
>>> type(response.follow(next_page))
<class 'scrapy.http.request.Request'>
を走りました。これはまったく可能ですか?どのような助けも非常に感謝します。
私は下記を試しましたが、エラーを修正できませんでした。
>>> scrapy.downloadermiddlewares.defaultheaders.DefaultHeadersMiddleware.process_request(response.follow(next_page), "quotes")
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: process_request() missing 1 required positional argument: 'spider'