发布时间:2019-09-04 06:54:50编辑:auto阅读(1960)
以登录我校系统为例:
1. 观察传输的包,填写内容登录
#_*_ coding:utf-8 _*_
import requests
url = 'https://cas.xjtu.edu.cn/login'
header = { 'User-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36'
}
#这是我从chrome f12里点登录后看到的传输的内容
from_data = {'username': 'xxx',
'password': 'xxx',
'code': '',
'lt': 'xxx',
'execution': 'e1s1',
'_eventId': 'submit',
'submit': '登录'
}
s = requests.session()
response = s.post(url, data = from_data, headers = header)
print response.status_code
2.利用cookie直接上
#_*_ coding:utf-8 _*_
import requests
url = 'https://cas.xjtu.edu.cn/login;jsessionid=084E35D36A4DA796BBB9A12E5E221BBE?service=http://my.xjtu.edu.cn/Login'
header = { 'User-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36',
'Cookie': 'xxx'
}
s = requests.session()
response = s.post(url, headers = header)
print response.status_code
上一篇: Python搭建插件式框架(基于组件开发
下一篇: python实现程序重启和系统重启
48900
47984
38758
35891
30318
27087
26097
20933
20750
19112
593°
670°
661°
667°
639°
610°
690°
755°
881°
1042°