Skip to content

Instantly share code, notes, and snippets.

@svecon
Created May 29, 2018 19:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save svecon/15bc707ba02bc1b4db5363207e4aa935 to your computer and use it in GitHub Desktop.
Save svecon/15bc707ba02bc1b4db5363207e4aa935 to your computer and use it in GitHub Desktop.
Download multiple images using Python
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