python下载图片的代码块

import urllib.request
imgurl="https://ss3.baidu.com/9fo3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=84337ed7c7134954611eee64664f92dd/ac6eddc451da81cbe337459b5e66d01608243197.jpg"

response = urllib.request.urlopen(imgurl)
cat_img = response.read()
 
with open('cat_500_600.jpg','wb') as f:
 f.write(cat_img)
 

posted @ 2018-05-04 17:50  Python研究者  阅读(778)  评论(0编辑  收藏  举报