Created
February 20, 2020 11:53
-
-
Save amirul12/8557b566eff3ec2b52b15869cc097211 to your computer and use it in GitHub Desktop.
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, 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