发布时间:2019-09-04 06:54:50编辑:auto阅读(1704)
以登录我校系统为例:
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实现程序重启和系统重启
47864
46428
37315
34762
29333
25991
24946
19968
19566
18051
5807°
6434°
5949°
5976°
7081°
5927°
5965°
6456°
6420°
7801°