我注意到 urllib.request.urlretrieve(url,fname_with_path)需要24秒才能下载任何小文件:
file1 file size: 3336
done in -24.33854389190674
file2 file size: 19252
done in -24.332698583602905
file3 file size: 62105
done in -24.43064308166504
file4 file size: 52405
done in -24.39844298362732
requests.get(url)时,下载相同文件的速度更快
file1 file size: 3336
done in -0.10920000076293945
file2 file size: 19252
done in -0.1716001033782959
file3 file size: 62105
done in -0.3120005130767822
file4 file size: 52405
done in -0.2652003765106201
问题是urllib花24秒下载文件的原因是什么?以及如何解决该问题以使其更快地醒来?
答案 0 :(得分:0)
尝试使用此处提供的解决方案:python downloading is extremely slow。通过将操作分为几个阶段(下载和写入文件),它帮助我加快了文件检索的速度。