Python download a image (or a file)

http://stackoverflow.com/questions/13137817/how-to-download-image-using-requests

import shutil

import requests

url = 'http://example.com/img.png'
response = requests.get(url, stream=True)
with open('img.png', 'wb') as out_file:
    shutil.copyfileobj(response.raw, out_file)
del response

 

posted @ 2016-08-09 15:50  龟窝  阅读(427)  评论(0编辑  收藏  举报