我正在尝试从以下链接中删除横幅图像(较大图像)的链接: https://allevents.in/pune/filmmaking-workshop/20001033616713 .为此,我尝试使用这两个命令,这两个命令都返回一个空列表。
https://allevents.in/pune/filmmaking-workshop/20001033616713
response.xpath('//img[@class="event-banner-image"]/@src').extract() response.xpath('//*[@class="event-banner-image"]/@src').extract()
我正在将Scrapy与Python结合使用。
实际上,您在页面源中查找的图像有多个源。
只需单击 ctrl键 + U (在某些浏览器上可能有所不同)以“查看页面源”并搜索url字符串。
我发现你可以在meta标签下面看到图像:
$ scrapy shell https://allevents.in/pune/filmmaking-workshop/20001033616713 In : response.xpath('//meta[@property="og:image"]/@content').extract() Out: ['https://cdn-az.allevents.in/banners/2d76d5624f4e4b83155a51d60b3872fb-rimg-w525-h350-gmir.jpg']