import requests # just a choice of comfort for me def download(url_address, filename): response = requests.get(url_address, stream=True) response.raise_for_status() with open(filename, "wb") as f: total_length = response.headers.get('content-length') if total_length is None: f.write(response.content) else: total_length = int(total_length) for data in response.iter_content(chunk_size = total_length / 100): f.write(data)