如果我不把这个寄到这里的话.但我们开始了。只是想尝试一些新的东西,并尝试和刮标题的产品和价格从这个网站。需要一些帮助,为什么我得到多个标题名称,为什么我不能得到的价格为我工作。
# -*- coding: utf-8 -*-
import scrapy
    class SpidervenderSpider(scrapy.Spider):
        name = 'spidervender'
        allowed_domains = ['www.woolworths.com.au/shop/productdetails/306165/red-bull-energy-drink']
        start_urls = ['https://www.woolworths.com.au/shop/productdetails/306165/red-bull-energy-drink']
    
        def parse(self, response):
    
            redbulls = response.xpath('//div')
    
            for redbull in redbulls:
                title = redbull.xpath('.//h1[@class="shelfProductTile-title heading3"]/text()').extract_first()
                price = redbull.xpath('.//shared-price/div/span[@class="price-dollars"]').extract_first()
                if title is not None:
                    print(title)
                print(price)https://stackoverflow.com/questions/61388434
复制相似问题