-
-
Save Limbicnation/94da3645c80b1ecf5d59b680c25de7d4 to your computer and use it in GitHub Desktop.
Download multiple images using Python
This file contains hidden or 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