在以逗号分隔的一列中通过 scrapy 提取 Woocommerce 产品图像

Extract Woocommerce Product Images via scrapy in one column seprated by comma

我正在使用 scrapy 创建数据抓取工具。要提取 woo-commerce 产品图像,我使用此命令

'img': response.css('figure.woocommerce-product-gallery__image a').attrib['href'],

产品Link:https://royalprint.pk/product/name-print-superhero-sweatshirt-011/

但它只在 csv

中提取一个 img url

我想在用逗号分隔的一列中抓取 Woocommerce 产品图片。

请帮忙。此致

试试这个:.getall() returns 包含所有结果的列表。

 response.css('figure.woocommerce-product-gallery__image a::attr("href")').getall()

输出:

['https://royalprint.pk/wp-content/uploads/2020/12/MaroonSweatshirtWonderWoman.jpg', 'https://royalprint.pk/wp-content/uploads/2020/12/G
reySweatshirtWonderWoman.jpg', 'https://royalprint.pk/wp-content/uploads/2020/12/BlueSweatshirtWonderWoman.jpg', 'https://royalprint.pk/
wp-content/uploads/2020/12/BlackSweatshirtWonderWoman.jpg', 'https://royalprint.pk/wp-content/uploads/2020/12/WhiteSweatshirtWonderWoman
.jpg', 'https://royalprint.pk/wp-content/uploads/2020/12/PinkSweatshirtWonderWoman.jpg']