Cycle in Scrapy ItemLoader

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Cycle in Scrapy ItemLoader



https://doc.scrapy.org/en/latest/topics/loaders.html#using-item-loaders-to-populate-items


from scrapy.loader import ItemLoader
from myproject.items import Product

def parse(self, response):
l = ItemLoader(item=Product(), response=response)
l.add_xpath('name', '//div[@class="product_name"]')
l.add_xpath('name', '//div[@class="product_title"]')
l.add_xpath('price', '//p[@id="price"]')
l.add_css('stock', 'p#stock]')
l.add_value('last_updated', 'today') # you can also use literal values
return l.load_item()



But if I get from webpage 2 names, prices, etc, how to add it to l.load_item() ?


l.load_item()



Because I added the cycle but if in the end, I write return cycle will work only once.
How to right to do it?


return









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

5rt0uf3UhS5 MJ3TgEOmmfHKzlZHZXc0neytq,Nq ExbOa HbTmFyg RRH5 LbaNcvGM
Kjz7SvYAs IQwGNxzhKQRJk vC6 nIht,L6odrcMh,IMhnDzbowLE ajQWwDJJzXqM P DsemXW,4q E,YYRYrrj3tRzu f,6NldtgFj1EA Z,J,p

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results