
1 different Nov 11, 2019 你这个够简洁,两行代码。怎么分析?起码描述一下你的 data 吧 |
2 yth492300648 OP |
3 pws22 Nov 11, 2019 具体没看,估计分析是你获取 formhash 的同时 将得到的 cookie 也一并带到登陆 post 上去 |
4 Vegetable Nov 11, 2019 骗人的,带上 cookie 就好了 ``` from requests import post url = 'https://bbs.colg.cn/member.php' params = dict( mod="logging", action="login", loginsubmit="yes", handlekey="login", loginhash="LFIX5", inajax="1") data = dict( formhash="62c5c2ef", referer="https://bbs.colg.cn/", loginfield="username", username="3123123", password="32131231", questiOnid="0", answer="", ) r = post(url, params=params, data=data, cookies={ "6KaR_be18_saltkey": "z9XWPZF4", "6KaR_be18_lastvisit": "1573457424", "6KaR_be18_pvi": "22566260", "6KaR_be18_si": "s1017261035", "pgv_pvi": "345539584", "pgv_si": "s2773357568", "6KaR_be18_sid": "GUByBi", "6KaR_be18_lastact": "1573461043%09member.php%09logging" }, headers={ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.87 Safari/537.36"}) print(r.text) ``` |
5 Lunatic1 Nov 11, 2019 之前遇到相同的问题解决了,应该跟 header 有关尝试加入 header,添加 'Content-Type': 'application/x-www-form-urlencoded' |
6 yth492300648 OP 不好意思 看来是自己傻逼了 @Lunatic1 |
7 yth492300648 OP @pws22 不好意思 看来是自己傻逼了 |
8 yth492300648 OP @Vegetable 不好意思 看来是自己傻逼了 |
9 yth492300648 OP @different 不好意思 看来是自己傻逼了 |