Reputation: 13
I am trying to remove \r\n
from the output in scrapy and I am using strip()
function but it's not working. Instead it's giving me the result back with \r\n
without any error. Why it's not working and How could I solve this problem?
def Regional_category(self, response):
items = response.meta['items']
names = {'name1':'Site Description'}
finder = {'finder1': '.site-descr::text}
for name, find in zip(names.values(), finder.values()):
items[name] = response.css(find.strip()).extract()
yield items
Upvotes: 1
Views: 272
Reputation: 59644
I think this should do it:
items[name] = response.css(find).extract().strip()
You were stripping the CSS selector, not the result.
If the result is a list of strings:
items[name] = list(map(str.strip, response.css(find).extract()))
Upvotes: 1