Web scraping 网页刮板不返回任何内容

Web scraping 网页刮板不返回任何内容,web-scraping,scrapy,Web Scraping,Scrapy,下面是我的webscraper代码,我遇到的问题是它没有返回任何东西。有人知道发生了什么事吗 import scrapy class QuotesSpider(scrapy.Spider): name = "quotes" allowed_domains = ['https://www.homedepot.ca'] start_urls = ['https://www.homedepot.ca/search?q=Malibu%20wide%20pl

下面是我的webscraper代码,我遇到的问题是它没有返回任何东西。有人知道发生了什么事吗

import scrapy


class QuotesSpider(scrapy.Spider):
    name = "quotes"
    allowed_domains = ['https://www.homedepot.ca']
    start_urls = ['https://www.homedepot.ca/search?q=Malibu%20wide%20plank%20french%20montara#!q=Malibu%20wide%20plank%20french%20montara']

    def parse(self, response):
        for quote in response.cs('div.quote'):
            title = quote.css('acl-product-card__title::text').getall()
            price = quote.css('acl-product-card__price::text').getall()
            combined = (title.text + ' ' + price.text)
            print(combined)



你确定它不会引发异常吗?这不应该起作用:

def parse(self, response):
    for quote in response.cs('div.quote'):
它应该是
response.css
而不是
response.cs

此外,您的起始url似乎已关闭。

也许它不接受我们国家的请求


如果它向您打开,您应该检查选择器以查看每个选择器返回的内容,这将允许您确定问题所在。

allowed\u domains
只获取域,其次,您应该在运行scraperhi时显示输出,这行得通吗?``def parse(self,response):title=response.css('acl-product-card\uu title::text')。getall()price=response.css('acl-product-card\uu price::text')。getall()composed=(title.text+“”+price.text)print(composed)``假设页面为您打开,选择器应该可以工作(如果css ref是正确的)。但是,您不应该调用
price.text
title.text
,因为您使用的
.getall()
方法将返回列表而不是对象<代码>打印(标题、价格)就可以了。