简体   繁体   English

如何使用Scrapy下载图像

[英]How to download images using Scrapy

I am trying to scrape: https://www.jny.com/products/cuff-sleeve-v-neck-top-floral-spice-combo 我正在尝试刮擦: https : //www.jny.com/products/cuff-sleeve-v-neck-top-floral-spice-combo

I want to download high resolution product images. 我想下载高分辨率的产品图片。 This is my code: 这是我的代码:

img= response.xpath('//div[@class="slick-track"]/li[@class = "image-track"]//img/@src').get()
print(img)

This is returning None. 这将返回无。 I have downloaded using Selenium but it is quite slower. 我已经使用Selenium下载了,但是速度很慢。 Is there any other solution? 还有其他解决方案吗?

Just try below xpath. 只需在xpath下尝试即可。

img= response.xpath('//div[@class="slick-track"]//li[@class = "image-track"]//img/@src').get()
print(img)

Snapshot: 快照:

Chrome开发者工具输出

Scrapy provides reusable item pipelines for downloading files attached to a particular item (for example, when you scrape products and also want to download their images locally). Scrapy提供了可重用的项目管道,用于下载附加到特定项目的文件(例如,当您抓取产品并且还想在本地下载其图像时)。 These pipelines share a bit of functionality and structure (we refer to them as media pipelines), but typically you'll either use the Files Pipeline or the Images Pipeline. 这些管道共享一些功能和结构(我们将它们称为媒体管道),但是通常您将使用“文件管道”或“图像管道”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM