Python 为什么我不能通过response.css获取所有图像链接?

Python 为什么我不能通过response.css获取所有图像链接?,python,web-scraping,scrapy,Python,Web Scraping,Scrapy,我正在尝试提取图像的所有链接,但我只能使用 response.css('div.col-sm-12 img.visible-print-block::attr(src)').get() 除此之外,当我尝试使用此代码提取其余图像时,我得到一个空数组。如何解决这个问题 class WebBox2Spider(scrapy.Spider): def parse(self, response): for prop in response.css('div.grid-item'

我正在尝试提取图像的所有链接,但我只能使用

response.css('div.col-sm-12 img.visible-print-block::attr(src)').get()
除此之外,当我尝试使用此代码提取其余图像时,我得到一个空数组。如何解决这个问题


class WebBox2Spider(scrapy.Spider):
    def parse(self, response):
        for prop in response.css('div.grid-item'):
            link = prop.css('div.property-image a::attr(href)').get()
            yield scrapy.Request(
                link,
                callback=self.get_loc,
                meta={'item': {
                    'url': link,
                }},
            )

    def get_loc(self, response):
        item = response.meta.get('item')

        pics_link =  response.css('div.gallery img::attr(src)').getall()

        item['images'] = pics_link

        return item

--------------------------------------------------------------------

class CapeWaterfrontSpider(WebBox2Spider):
    name = "cape_waterfront_estates"
    start_urls = ['https://www.capewaterfrontestates.co.za/template/Properties.vm/listingtype/SALES',
                  'https://www.capewaterfrontestates.co.za/template/Properties.vm/listingtype/MONTHLY_RENTAL']

您可以使用ScrapyShell检查scrapy的html外观。您尝试获取的内容是动态加载的,因此您必须将选择器调整为,例如:pics_link=response.xpath'/*[@data nav=thumbs]/@data full'。提取

非常感谢,这很有帮助!