Skip to content

Instantly share code, notes, and snippets.

@yanqd0
yanqd0 / dl_requests_tqdm.py
Last active May 17, 2025 18:26
Python requests download file with a tqdm progress bar
import requests
from tqdm import tqdm
def download(url: str, fname: str, chunk_size=1024):
resp = requests.get(url, stream=True)
total = int(resp.headers.get('content-length', 0))
with open(fname, 'wb') as file, tqdm(
desc=fname,
total=total,