scrapy item loaders code example
Example 1: scrapy itemloader example
def join_tags(value):
return ','.join([i for i in value if i])
Example 2: scrapy itemloader example
def _extract_item(self, response):
l = ItemLoader(response=response, item=MyspiderItem(), type='html')
l.add_xpath('movie_name', '//h1/span[@property="v:itemreviewed"]/text()')
l.add_xpath('movie_year', '//span[@property="v:initialReleaseDate"]/text()')
l.add_xpath('movie_type', '//span[@property="v:genre"]/text()')
l.add_xpath('movie_rate', '//strong[@class="ll rating_num"]/text()')
l.add_value('url', response.url)
return dict(l.load_item())