def test_003(): get_url = 'https://gin/MDAccountLogin' data = { "password": "jTkwfPUxBN2LIJJPlfeGMxbwjsVHTB+vsJI48EN", "isCookie": False, "captchaType": 1, "account": "FL+6ybJ6uXdOF0IkTkbB3yeNSHPvFG89cDMjfQnqHjdYk" } headers = {"content-type": "application/json"} res = requests.post(url=get_url, data=json.dumps(data), headers=headers) print("请求头:%s" % res.headers) print("响应头:%s" % res.request.headers) cookie = res.cookies.get_dict().get("md_pss_id") print("cookie: %s" % cookie)
def test_04(): session = requests.session() get_url = 'https://cooperation.uniontech.com/wwwapi/Login/MDAccountLogin' data = { "password": "jTkwfEnaQeb9u5A1Gx6h3CwsfEVcOWPdwyFicnyW4MCo/blACFl8FXFsWrVimWWAZwHFPUxBN2LIJJPlfeGMxbwjsVHTB+vsJI48ENEWUN6s1BmMH4cWYTTd8X+aULRzl4tYr7ua0EQyON3dKpBFuTrWzYdA3UQ0fAnbCLLf0/s=", "isCookie": False, "captchaType": 1, "account": "kXn8/7KY9cJJ19uX60j3xCXefMszzZbmOKu1emMxsocPRmpFL+6ybJ6uXdOF0IkTkbB3yeNSHPvFG89cDMjfQnqHjdYkb2oTqB/KOOqp/JgUE90fV3s3U4jcn2bwnFF12SxMf2TkiC7Np+QwkgcYatvatDUra2ywrUyaEK/M4uU=" } headers = {"content-type": "application/json"} res = session.post(url=get_url, data=json.dumps(data), headers=headers) print("请求头:%s" % res.headers) print("响应头:%s" % res.request.headers) cookie = res.cookies.get_dict().get("md_pss_id") print("cookie: %s" % cookie)
标签:get,res,接口,headers,cookie,自动化,print,data From: https://www.cnblogs.com/xxx1234-11225/p/17672129.html