Issue
I want to remove these from my output: I want these only Wave Coffee Collection
'\n\n\t\t3rd Wave Coffee Collection\n\t\t\t\t\n\t'
This is my code :
from scrapy.http import Request
import scrapy
class PushpaSpider(scrapy.Spider):
name = 'pushpa'
start_urls = ['https://onepagelove.com/inspiration']
def parse(self, response):
books = response.xpath("//div[@class='thumb-image']//a//@href").extract()
for book in books:
absolute_url = response.urljoin(book)
yield Request(absolute_url, callback=self.parse_book)
def parse_book(self, response):
title = response.xpath("//span[@class='review-name']//h1//text()").extract_first()
yield{
'title':title
}
Solution
If this is your resulting output:
result = '\n\n\t\t3rd Wave Coffee Collection\n\t\t\t\t\n\t'
Then you can easily achieve your desired output like this:
result = result.strip()
Answered By - Richard
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.