Han*_*mes 1 python scrapy web-scraping python-3.x woocommerce
我正在使用 scrapy 创建一个数据抓取器。要提取 woo-commerce 产品图像,我使用此命令
'img': response.css('figure.woocommerce-product-gallery__image a').attrib['href'],
Run Code Online (Sandbox Code Playgroud)
产品链接:https://royalprint.pk/product/name-print-superhero-sweatshirt-011/
但它只提取 csv 中的一个 img url
我想将 Woocommerce 产品图片抓取到以逗号分隔的一列中。
请帮忙。问候
试试这个:.getall()返回包含所有结果的列表。
response.css('figure.woocommerce-product-gallery__image a::attr("href")').getall()
Run Code Online (Sandbox Code Playgroud)
输出:
['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']
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
733 次 |
| 最近记录: |