【问题标题】:I'm trying to download some image from whatsapp web我正在尝试从whatsapp web 下载一些图片
【发布时间】:2020-05-22 11:23:44
【问题描述】:

我找到了一种识别图像的方法,但不知道如何获取它们的 URL。

部分代码:

images = driver.find_elements_by_tag_name('img')
for image in images:
    sticker = # <idk how to get the URL> 
    url.urlretrieve(sticker)

顺便说一句,如果有最好的下载方式,我会很高兴听到一些建议。

【问题讨论】:

    标签: python-3.x selenium selenium-webdriver urllib urllib3


    【解决方案1】:

    不妨试试:

    src = image.get_attribute('src')
    
    # download the image
    urllib.urlretrieve(src, "image.png")
    

    这假设图像标签中有一个属性 src。

    【讨论】:

    • 我实际上得到了这个错误:raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 500: Internal Server Error
    • 不知道为什么,也许看看stackoverflow.com/questions/15912257/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-08
    • 2012-05-03
    • 2017-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多