鱼C论坛

 找回密码
 立即注册
查看: 1565|回复: 2

[已解决]python requests库的post问题

[复制链接]
发表于 2020-11-6 22:48:53 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 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 抓取信息

原来正常的post

模拟的post 抓取信息

模拟的post 抓取信息

模拟的post
最佳答案
2020-11-6 23:18:10
本帖最后由 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'=''
})
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2020-11-6 23:18:10 | 显示全部楼层    本楼为最佳答案   
本帖最后由 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'=''
})
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-11-7 10:13:24 | 显示全部楼层
kogawananari 发表于 2020-11-6 23:18
requests.post(post_addr,headers=post_header, data= {
    'DDDDD'=',0,201509120317@cmcc',
    'upas ...

太感谢了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-1-17 23:13

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表