Skip to content

Instantly share code, notes, and snippets.

@tinshade
Created July 3, 2021 08:45
Show Gist options
  • Save tinshade/8b52671f65e65b2c538385a370c428ad to your computer and use it in GitHub Desktop.
Save tinshade/8b52671f65e65b2c538385a370c428ad to your computer and use it in GitHub Desktop.
Simple python script to download image via URL
import requests
import base64
def imageTest(url):
return base64.b64encode(requests.get(url).content)
def writeback(image):
decodeit = open('myimage.png', 'wb')
decodeit.write(base64.b64decode((image)))
decodeit.close()
#Image credits : https://unsplash.com/@melimascella_
image = imageTest('https://images.unsplash.com/photo-1625252568254-256958377c1d?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80')
writeback(image)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment