python下载图片到本地路径

import requests
from urllib.request import urlretrieve


IMAGE_URL = "http://47.104.63.70:5728/oauth2/captcha.jpg"

#使用urlretrieve来下载图片
# urlretrieve(IMAGE_URL,'D:\\yunduan_pyzdh\\yzm\\00.jpg')

#使用requests直接get
import requests
r = requests.get(IMAGE_URL)
with open('D:\\yunduan_pyzdh\\yzm\\02.jpg', 'wb') as f:
    f.write(r.content)
posted @ 2022-04-24 14:23  向前、向前  阅读(169)  评论(0编辑  收藏  举报