r = s.get(loginurl, verify=False) dom = etree.HTML(r.content.decode("utf-8")) try: result["lt"] = dom.xpath('//input[@name="lt"]')[0].get("value") result["execution"] = dom.xpath('//input[@name="execution"]')[0].get("value") print(result) except: print("lt、execution参数获取失败!") return result
body = { "username": user, "password": psw, "rememberMe": "true", "lt": result["lt"], "execution": result["execution"], "_eventId": "submit" } s.headers.update(h2) r4 = s.post(loginurl, data=body, verify=False) print(r4.text)