how to save an image from a url and save it in a specific folder

Using the requests pkg:

import requests
image_url = "https://storage.labelbox.com/ckh4cqkd7y8r30721vlr7m5he%2F7bc29750-7fcc-dbac-7683-1b67125d7afd-Y62Y62.jpg?Expires=1604685570096&KeyName=labelbox-assets-key-1&Signature=sEhvkl3MUnT2iiuFZsvwFLqzAE8"
path = "/Users/naghmeh/Documents/medical/jadid/train/asd.jpg"
request = requests.get(image_url, stream=True)
with open(path, "wb+") as file:
  for c in request:
    file.write(c)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top