Created
May 29, 2018 19:48
-
-
Save svecon/15bc707ba02bc1b4db5363207e4aa935 to your computer and use it in GitHub Desktop.
Download multiple images using 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 | |
def DownloadImage(pic_url_prefix, pic_name): | |
with open(pic_name, 'wb') as handle: | |
response = requests.get(pic_url_prefix+pic_name, stream=True) | |
if not response.ok: | |
print(pic_url_prefix+pic_name, response) | |
for block in response.iter_content(1024): | |
if not block: | |
break | |
handle.write(block) | |
for i in range(367): | |
DownloadImage( | |
'<<YOUR URL HERE>>', | |
'<<YOUR IMAGE NAME HERE>>-{:03}.jpg'.format(i) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment