Search code examples
python-3.xselenium-webdriverurllib

how can i get the url from a specific image with selenium / python?


I'm trying to download some image from whatsapp web. I found a way to identify the images but idk how to get their URL.

part of the code:

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

btw if there's a best way to download the, I'll be glad to hear some advises.


Solution

  • The src attribute holds that information.

    images = driver.find_elements_by_tag_name('img')
    for image in images:
        sticker=image.get_attribute('src')
        url.urlretrieve(sticker)