python requests库的post问题
本帖最后由 kissguan 于 2020-11-6 22:50 编辑用finddler抓了学校登录的post请求,如下
POST http://1.1.1.1:801/eportal/?c=ACSetting&a=Login&protocol=http:&hostname=1.1.1.1&iTermType=1&wlanuserip=10.133.2.63&wlanacip=null&wlanacname=null&mac=00-00-00-00-00-00&ip=10.133.2.63&enAdvert=0&queryACIP=0&loginMethod=1 HTTP/1.1
Host: 1.1.1.1:801
Connection: keep-alive
Content-Length: 164
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://1.1.1.1
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://1.1.1.1/
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: program=NEW; vlan=0; ssid=null; areaID=null; ip=10.133.2.63; ISP_select=@cmcc; md5_login2=%2C0%2C201509120317@cmcc%7C285500; PHPSESSID=848vkq448g1ccr8ec0lu4ocac4
DDDDD=%2C0%2C201509120317%40cmcc&upass=285500&R1=0&R2=0&R3=0&R6=0¶=00&0MKKey=123456&buttonClicked=&redirect_url=&err_flag=&username=&password=&user=&cmd=&Login=
想用python模拟发送这个类型的post,百度了一波用自己的账号信息写成这个样子了,运行一遍发现抓到的请求里顺序变了,而且最后一行的DDDDD开头的这一堆data不知道咋写,求大佬指点
import requests
post_addr = 'http://1.1.1.1:801/eportal/?c=ACSetting&a=Login&protocol=http:&hostname=1.1.1.1&iTermType=2&wlanuserip=10.133.126.65&wlanacip=null&wlanacname=null&mac=00-00-00-00-00-00&ip=10.133.126.65&enAdvert=0&queryACIP=0&loginMethod=1 HTTP/1.1'
post_header = {
"Host": "1.1.1.1:801",
"Connection": "keep-alive",
"Content-Length": "0",
"Cache-Control": "max-age=0",
"Upgrade-Insecure-Requests": "1",
"Origin": "http://1.1.1.1",
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"Referer": "http://1.1.1.1/",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9",
"Cookie": "vlan=0; program=NEW; ssid=null; areaID=null; ISP_select=@cmcc; md5_login2=%2C0%2C2018109142@cmcc%7C207816; ip=10.133.126.65; PHPSESSID=86ht3ag16rldb61gh2idb8hjd6",
}
print(post_header)
requests.post(post_addr,headers=post_header)
原来正常的post
模拟的post 本帖最后由 kogawananari 于 2020-11-6 23:19 编辑
requests.post(post_addr,headers=post_header, data= {
'DDDDD'=',0,201509120317@cmcc',
'upass'=285500,
'R1'=0,
'R2'=0,
'R3'=0,
'R6'=0,
'para'=00,
'0MKKey'=123456,
'buttonClicked'='',
'redirect_url'='',
'err_flag'='',
'username'='',
'password'='',
'user'='',
'cmd'='',
'Login'=''
}) kogawananari 发表于 2020-11-6 23:18
requests.post(post_addr,headers=post_header, data= {
'DDDDD'=',0,201509120317@cmcc',
'upas ...
太感谢了
页:
[1]