python+requests 验证码登录

 

  1. 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

posted @ 2020-10-30 15:33  楼宇  阅读(1145)  评论(0编辑  收藏  举报