python+requests 验证码登录
-
1、先创建一个session req = requests.session() 2、通过session来把验证码下载到本地, code = req.get("https://passport.company-pvt.tongtool.com/captcha.jpg", headers=headers) with open('code.jpg', 'wb') as file: file.write(code.content) file.close 3、使用fiddle对登录请求分析,传入的参数如下,其中cap为手工输入的验证码 data = {"u": "", "haveRisk": "https://twerp-staging.tongtool.com/#/goods/mygoods", "username": "******", "password": "****", "captcha": cap} 4、执行登录 login = req.post(url, headers=headers, params=data)
https://blog.csdn.net/zhouxuan623/article/details/107230683