【问题标题】:Scrapy Image Returns NoneScrapy 图像返回无
【发布时间】:2021-03-09 01:24:42
【问题描述】:

我正在尝试从这张图片中抓取代码

<img alt="Prata Bom Cheese" class="realImage___2TyNE" src="https://d1sag4ddilekf6.cloudfront.net/compressed/items/SGITE20200430045730017104/photo/menueditor_item_922ff3e4ed464a32a1a0e5f02f4c383d_1589715446971551288.jpg" style="opacity: 1;">

用我的代码

imgURL = res.css('img').xpath('@src').extract_first()
n = res.css('img').xpath('@alt').get() 
yield ImagespiderItem(name = n, file_urls = [imgURL])

但由于某种原因,scrapy 不会提取 src。它仍然会提取alt 和其他属性。我已经尝试了一切,但我被困在这里。谁能帮我?我真的很感激。

【问题讨论】:

  • 能否给个源网页地址?

标签: python web-scraping scrapy


【解决方案1】:

试试这个

response.css('.realImage___2TyNE ::attr(src)').get()

【讨论】:

    猜你喜欢
    • 2017-12-24
    • 1970-01-01
    • 2017-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多