0
点赞
收藏
分享

微信扫一扫

python爬虫通过图片网址保存图片


import requests

imgUrl = 'http://img3m0.ddimg.cn/9/25/1674043380-1_b_1.jpg'
headers = {
'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Mobile Safari/537.36'
}
res = requests.get(imgUrl, headers=headers).content
print(res)

name = '3'
with open(name + '.jpg', 'wb') as f:
f.write(res)


举报

相关推荐

0 条评论