Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import time
- def download_image(list_pict):
- start_time = time.time()
- for number, url in enumerate(list_pict, 1):
- response = requests.get(url, stream=True)
- with open(f"image_{number}.jpg", "wb") as file:
- # Запись кусками файла
- for chunk in response.iter_content(chunk_size=1024*1024):
- if chunk:
- file.write(response.content)
- print(time.time() - start_time)
- if __name__ == '__main__':
- list_image_urls = [
- "https://pbs.twimg.com/media/FKSEbAIXsAIRxY4?format=jpg&name=900x900",
- "https://pbs.twimg.com/media/Es7CI89WMAAB2ap?format=jpg&name=4096x4096",
- "https://pbs.twimg.com/media/Es7CYjNXEAMo_Bm?format=jpg&name=4096x4096",
- "https://pbs.twimg.com/media/Es7CZhXXEAIuBMT?format=jpg&name=4096x4096",
- "https://pbs.twimg.com/media/EiSwI54U4AEt_B2?format=jpg&name=900x900"
- ]
- download_image(list_image_urls)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement