Created
March 5, 2020 05:05
-
-
Save asadamatic/5b70be24d3975329045ebc31dc755ffb to your computer and use it in GitHub Desktop.
Code to donwload images using requests library in python.
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 time | |
imageUrl = 'https://images.unsplash.com/photo-1558981396-5fcf84bdf14d' | |
image = requests.get(imageUrl) | |
imageBytes = image.content | |
fileName = imageUrl.split('/')[3] + '.png' #getting photo name from the url | |
with open(fileName , 'wb') as file: #Openning a new file in 'Write Bytes' mode | |
file.write(imageBytes) | |
print('Finished downloading image :)') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment