这里有2种方法,我这里是因为要保存验证码到本地:
import requests
from urllib.request import urlretrieve
#r = requests.get('')
#获取验证码
IMAGE_URL = "http://47.104.63.70:5728/oauth2/captcha.jpg"
#使用urlretrieve来下载图片
# IMAGE_URL = "http://47.104.63.70:5728/oauth2/captcha.jpg"
# 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)
执行一遍后取路径查看,