Created
July 3, 2021 08:45
-
-
Save tinshade/8b52671f65e65b2c538385a370c428ad to your computer and use it in GitHub Desktop.
Simple python script to download image via URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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