Skip to content

Instantly share code, notes, and snippets.

@amirul12
Created February 20, 2020 11:53
Show Gist options
  • Save amirul12/8557b566eff3ec2b52b15869cc097211 to your computer and use it in GitHub Desktop.
Save amirul12/8557b566eff3ec2b52b15869cc097211 to your computer and use it in GitHub Desktop.
import requests
def DownloadImage(pic_url_prefix, pic_name):
with open(pic_name, 'wb') as handle:
response = requests.get(pic_url_prefix, stream=True)
if not response.ok:
print(pic_url_prefix, response)
for block in response.iter_content(1024):
if not block:
break
handle.write(block)
for i in range(100):
DownloadImage(
'https://i.picsum.photos/id/{}/512/512.jpg'.format(i),
'name-{:03}.jpg'.format(i)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment