使用scrapy获取第一个图像URL



我正在尝试使用 xpath@src获取第一个 url"https://example.com/example.jpg",但结果总是/Content/images/defaultThumb.jpg

<img class="pimg" src="https://example.com/example.jpg" onerror="this.src = '/Content/images/defaultThumb.jpg'" title="test" alt="test" style="">

你的 xpath 错了,试试这个...

scrapy shell "https://www.trendyol.com/versace?qt=versace"
response.xpath('//img[@class="primg lazy"]/@data-original').extract()

最新更新