scrapy / itemloaders

Library to populate items using XPath and CSS with a convenient API
BSD 3-Clause "New" or "Revised" License
45 stars 16 forks source link

Fluent Interface call-style for ItemLoader methods #54

Closed suspectinside closed 6 months ago

suspectinside commented 2 years ago

Hi, it should be very helpfull if you add ability to call ItemLoader's methods (like add_xpath, add_css etc) fluently:

loader = (ItemLoader(selector=Selector(html_data))
    .add_xpath('name', '//div[@class="product_name"]/text()')
    .add_xpath('name', '//div[@class="product_title"]/text()')
    .add_css('price', '#price::text')
    .add_value('last_updated', 'today')
)

item = loader.load_item()

This is really a very tiny change - just add return self into the appropriate methods