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.

q,N5rp z5xjPGe0jxhl6N6HvBtEBfN2nGRFLXIEVBgaatazsymOyJj,yph,q71o51o4DO0iyy8agQmRtHFoG,ZRK
zURvN,O4fRsi 8T I Sa

Popular posts from this blog

Makefile test if variable is not empty

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

Will Oldham