繁体   English   中英

为什么我的 Python POST 请求会引导我进入初始网页?

[英]Why does my Python POST request lead me to the initial webpage?

我是这个论坛的新手,对编码也比较陌生

这个问题已经在这里问过了,但解决方案似乎对我不起作用。

我想使用 Python 发布请求登录 index.php 页面,但响应 url 仍然与初始登录页面相同,表明登录不成功。

import requests as r

login_url = "https://www.example.com/index.php?login"
index_url = "https://www.example.com/gymla/index.php" #The url I want to be directed to

data = {
    "isiwebuserid": "username",
    "isiwebpasswd": "password",
    "submit": "Senden"
}

s = r.session()
response = s.post(login_url, data=data)

print(response.url)
if response.url == login_url:
    print("The attempt did not work.")

如果登录 URL 可能是错误的,我已经检查了 <form action,但它似乎没问题。 表格资料也齐全。 还有什么可能是错的?

Url 不改变但保持固定,试试这个

if response.status_code != 200:
    print("The attempt did not work.")

谢谢你们回答我的问题。 解决方案确实是使用"Submit"而不是"Senden"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM