0

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.

ToboBaldo
  • 15
  • 4

1 Answers1

1

Maybe try:

src = image.get_attribute('src')

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

This assumes there is an attribute src in the image tag.

Peter
  • 848
  • 8
  • 14
  • i actually get this error: raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 500: Internal Server Error – ToboBaldo May 25 '20 at 10:03
  • Not sure why that is, maybe look at https://stackoverflow.com/questions/15912257/500-error-with-urllib-request-urlopen – Peter May 25 '20 at 14:32