简体   繁体   中英

Get response from the request in Scrapy

is there a way i can return a response from my parse method?

I tried this:

yield {
    'content': scrapy.Request(url, callback=self.parse_page),
}

but the response is:

'content': <GET https://example.com>

I expect the result would be like this:

'content': 'some text'

as the parse_page() method is parsing from some css selector.

Thank you and sorry for my bad english.

It is object:

scrapy.Request(url, callback=self.parse_page)

Parameter body, this is what you need:

response = scrapy.Request(url, callback=self.parse_page)
content = response.body
yield {
    'content': content,
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM