[英]Why does my Python POST request lead me to the initial webpage?
I am new to this Forum and relatively new to coding我是这个论坛的新手,对编码也比较陌生
This question has already been asked here but the solutions didn't seem to work for me.这个问题已经在这里问过了,但解决方案似乎对我不起作用。
I'd like to log into the index.php page using a Python Post request, but the response url remains the same with the intitial login page indicating that the login was not successful.我想使用 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.")
I've checked with <form action if the login URL might be wrong, but it seems alright.如果登录 URL 可能是错误的,我已经检查了 <form action,但它似乎没问题。 The form data is also complete.
表格资料也齐全。 What else could be wrong?
还有什么可能是错的?
Url does not change but remains fixed, Try this Url 不改变但保持固定,试试这个
if response.status_code != 200:
print("The attempt did not work.")
Thank you guys for answering my question.谢谢你们回答我的问题。 The solution was indeed to use "Submit" instead of "Senden" .
解决方案确实是使用"Submit"而不是"Senden" 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.