Answer the question
In order to leave comments, you need to log in
Scrapy - input_processor?
Hi all!
items.py:
import scrapy
from scrapy.loader.processors import MapCompose
def filter_spaces(value):
return value.strip(" ").strip("\n")
class LotItem(scrapy.Item):
num = scrapy.Field(input_processor=MapCompose(filter_spaces))
def parse_item(self, response):
item = LotItem()
item['num'] = response.xpath('//div/span/text()').extract()[0]
yield item
"\n1234 "
Answer the question
In order to leave comments, you need to log in
Is not
item['num'] = response.xpath('//div/span/text()').extract()[0]
item = LotItem()
item['num'] = response.xpath('//div/span/text()').extract()[0].strip()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question