def login_form(login_url, passkey):
html = requests.get(login_url)
response = requests.post(login_url, data = passkey, cookies =
html.cookies)
return response
passkey = { "username": "pass", "password": "password"}
login_info = login_form('https://www.cpaelites.com/member.php?action=login',
passkey)
print(login_info.url)
返回URL响应与登录相同。但它没有显示任何错误 我尝试在cpaelites上自动执行登录过程,我没有显示任何错误,但是当我打印响应URL时,它显示我仍然在当前页面,这意味着我没有登录成功
答案 0 :(得分:0)
您正在data
传递凭据,您可以尝试使用auth
参数
from requests.auth import HTTPBasicAuth
def login_form(login_url, passkey):
html = requests.get(login_url)
response = requests.post(login_url, auth = HTTPBasicAuth(passkey['username'], passkey['password']), cookies = html.cookies)
return response
passkey = { "username": "pass", "password": "password"}
login_info = login_form('https://www.cpaelites.com/member.php?action=login', passkey)
print(login_info.url)