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"
}
im_url = 'http://121.251.136.100/jwxt/sys/ValidateCode.aspx'
# 获取响应图片内容
image = sess.get(im_url, headers=headers).content
# 保存到本地
path = 'F:\Python\code\\'
name = str(i)+".jpg"
with open(path+name, "wb") as f:
f.write(image)
if __name__ == "__main__":
# 获取100张图片
for i in range(100):
downimage(i)
【Python】获取验证码
猜你喜欢
转载自blog.csdn.net/qq_36664584/article/details/81013879
今日推荐
周排行