Getting less speed while downloading file using request

Viewed 16

I have a downloading speed of 2mbps but while downloading file with the code i get only 300-4000 kb, Here is the code i am using

response = requests.get(url, stream=True)
     total_size_in_bytes= int(response.headers.get('content-length', 0))
     block_size = 1024 #1 Kibibyte
     progress_bar = tqdm(total=total_size_in_bytes, unit='iB', unit_scale=True)
     
        
     
     print("downlaoding.."+name.replace("%",""))
     with open('C:/Users/NAMIT/Downloads/New folder/'+name, 'wb') as file:
        for data in response.iter_content(block_size):
           progress_bar.update(len(data))
           file.write(data)
     progress_bar.close()
0 Answers
Related