DEV Community

Discussion on: Extract all the data! – 02 – Python scrapy tutorial for beginners

Collapse
khoithinh profile image
Khoi Thinh

Hi David,

Old code

for book in all_books:
book_url = self.start_urls[0] +
book.xpath('.//h3/a/@href').extract_first()

New code

yield scrapy.Request(book_url, callback=self.parse_book)

def parse_book(self, response):
print(response.status)

I got an error saying book_url is not defined, can you post full code of this section?