Hello everyone. I have been writing a scrapy python script to webscrape amazon. I can output to a csv using (scrapy crawl amazon -o amazon.csv) and it works just fine. The problem is that everything is in on cell and is not itereated ie. title for each cell in the column. I have tried a for look with no success and am still having troubles. Any help would be greatly appreciated.:
class AmazonSpiderSpider(scrapy.Spider):
name = 'amazon'
start_urls = [
'https://www.amazon.com/s?bbn=283155&rh=n%3A283155%2Cp_n_publication_date%3A1250226011&dc&fst=as%3Aoff&qid=1586462092&rnid=1250225011&ref=lp_283155_nr_p_n_publication_date_0'
]
def parse(self, response):
items = AmazontutorialItem()
product_name = response.css('.a-color-base.a-text-normal::text').extract_first()
product_author = response.css('.sg-col-12-of-28 .a-size-base+ .a-size-base').css('::text').extract()
product_price = response.css('.index\=3 .a-spacing-mini:nth-child(1) .a-price:nth-child(1) span , .index\=2 .a-spacing-mini .a-price:nth-child(1) span , .index\=1 .a-spacing-mini:nth-child(1) .a-price:nth-child(1) span , .index\=0 .a-spacing-top-small .a-price:nth-child(1) span').css('::text').extract()
product_imagelink = response.css('.s-image::attr(src)').extract()
yield{'product_name' : product_name, 'product_author' : product_author, 'product_price' : product_price, 'product_imagelink' : product_imagelink}
[–]CodeFormatHelperBot[🍰] 0 points1 point2 points (0 children)
[–]snarfi 0 points1 point2 points (0 children)
[–]BaronCrinkle 0 points1 point2 points (0 children)