转载:https://blog.csdn.net/t8116189520/article/details/78899801
# coding:utf8
import requests
def downimage(i):
# 构建session
sess = requests.Session()
# 建立请求头
headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.75 Safari/537.36",
"Connection": "keep-alive"}
# 这个url是联合航空公司验证码,根据访问时间戳返回图片
url="https://account.flycua.com/sso/chineseVerifyCode.images"
# 获取响应图片内容
image=sess.get(url,headers=headers).content
# 保存到本地
with open(str(i)+"image.jpg","wb") as f:
f.write(image)
if __name__=="__main__":
# 获取10张图片
for i in range(10):
downimage(i)
阅读(1743) | 评论(0) | 转发(0) |