One - One Code All

Blog Content

Python流式分块下载Response.iter_content

Python   2014-07-22 12:19:03
url = "abc.jpg"

rsp = requests.get(url, stream=True)
with open('1.jpg', 'wb') as f:
    for i in rsp.iter_content(chunk_size=1024):  
    # 边下载边存硬盘, chunk_size 可以自由调整为可以更好地适合您的用例的数字
        f.write(i)



上一篇:浏览器插件之广告终结者
下一篇:python性能分析器Profile

The minute you think of giving up, think of the reason why you held on so long.