【问题标题】:Extract Woocommerce Product Images via scrapy in one column seprated by comma通过scrapy在以逗号分隔的一列中提取Woocommerce产品图像
【发布时间】:2020-12-17 20:07:30
【问题描述】:

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

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

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

但它只在 csv 中提取一个 img url

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

请帮忙。问候

【问题讨论】:

    标签: python python-3.x web-scraping woocommerce scrapy


    【解决方案1】:

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

     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']
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-05
      • 1970-01-01
      • 2022-01-01
      • 1970-01-01
      • 2018-11-17
      • 2011-05-26
      • 1970-01-01
      • 2012-04-28
      相关资源
      最近更新 更多