Last active
August 30, 2020 04:53
-
-
Save pn11/acf4d75bd2e995690e9df4139d223d51 to your computer and use it in GitHub Desktop.
Download images from a website. keywords: scraping, requests, 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 | |
import time | |
from tqdm import tqdm | |
base_url = 'http://xxxxx.xxx/{image_id}.jpg' | |
def get_image(image_id): | |
r = requests.get(base_url.format(image_id=image_id)) | |
with open(f"{image_id}.jpg", 'wb') as f: | |
f.write(r.content) | |
time.sleep(1.0) | |
if __name__ == '__main__': | |
for i in tqdm(range(1, 100)): | |
get_image(i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment