Skip to content

Instantly share code, notes, and snippets.

View Alirex's full-sized avatar
👁️‍🗨️
Observing

Alirex Prime Alirex

👁️‍🗨️
Observing
  • Cryeye
View GitHub Profile
@Alirex
Alirex / download_multiple.py
Created April 26, 2020 18:22 — forked from Hammer2900/download_multiple.py
Use asyncio and aiohttp to asynchronously download multiple files at once and handle the responses as they finish
import asyncio
from contextlib import closing
import aiohttp
async def download_file(session: aiohttp.ClientSession, url: str):
async with session.get(url) as response:
assert response.status == 200
# For large files use response.content.read(chunk_size) instead.