#coding:utf-8 import requests import re url="http://localhost:8080/j_acegi_security_check" headers={ "Connection": "keep-alive", "Content-Length": "xx", "Cache-Control": "xx", "Origin": "http://localhost:8000", "Upgrade-Insecure-Requests":"xx" , "Content-Type":"application/x-www-form-urlencoded", "User-Agent": "xxxx", "Accept":"xxx", "Referer": "http://localhost:8000/login?from=%2F", "Accept-Encoding": "gzip, deflate", "Accept-Language": "zh-CN,zh;q=0.9", "Cookie": "xxxxx" } data={ "j_username":"xxx", "j_password":"xxxx", "from":"", "remember_me":"on", "Submit":"Sign in" } r=requests.post(url,headers=headers,data=data) print(r.content) print(r.status_code) #正则表达式提取账号和登陆按钮 t=re.findall(r'<b>(.+?)</b>',r.content.decode("utf-8")) print(t[0]) print(t[1])
python接口测试登陆jenkins代码
最新推荐文章于 2024-05-27 14:07:49 发布