?piu 2023-03-21 17:20 采纳率: 20%
浏览 11

Scrapy可以获取到标题但是无法获取到价格

img


    def parse(self, response):
        print(response, response.url, '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-')
        sections = response.xpath('.//section[@class="list"][1]/div')
        print(len(sections))

        for section in sections:
            title = section.xpath('./a/div[2]/div[1]/div/h3/@title').extract_first()
            total_price = section.xpath('/a/div[2]/div[2]/p[1]/span/text()').extract
            print(title, '\n', total_price )

img

  • 写回答

1条回答

  • 奔跑哥 2023-03-22 10:01
    关注

    p[0]吧,或者你直接用class查找不香吗

    评论

报告相同问题?

问题事件

  • 创建了问题 3月21日