0

我需要他们的帮助来请求单击带有 python 和请求的按钮。

表单的 HTML 代码是这样的:

<form action="someurl/changedata" enctype="multipart/form-data" method="POST">
<p class="message">
Description
</p>
<div class="data-field-grouping" data-field-grouping-name="Passwords">
<div class="data-field" data-field-name="OldPassword">
<label data-required="data-required" for="OldPassword">Old Password</label><input id="OldPassword" maxLength="128" name="OldPassword" required="required" type="password" /></div>
<div class="data-field" data-field-name="Password">
<label data-required="data-required" for="Password">New Password</label><input id="Password" maxLength="128" name="Password" required="required" type="password" /></div>
<div class="data-field" data-field-name="PasswordConfirmation">
<label data-required="data-required" for="PasswordConfirmation">Confirm Password</label><input id="PasswordConfirmation" maxLength="128" name="PasswordConfirmation" required="required" type="password" /></div>
</div>
<input name="__RequestVerificationToken" type="hidden" value="xwvDA9Y-bzAY4Z9F3UVSnuFlYEuVfD2F8kYY4aD__wKzjQct7y6JZ4Jd6_YpxhQIXq0zcRJ-RfLxleHgT49P-lMecIB55LEyXCMylaTxK1KzI_HqbWM101FGmaK33Y2z0" /><button type="submit">Change Password</button></form>

我一直在尝试使用此代码并且登录成功,但下一部分没有,好吧。它不会给我错误,而只会给我正文的 html。

import requests
from requests_ntlm import HttpNtlmAuth

info = {'OldPassword':'firstpass',
        'Password':newpass,
        'PasswordConfirmation': newpass,
        '__RequestVerificationToken':'0'
}

s = requests.session()
with requests.session() as s: 
    responsee = s.get("url",auth=HttpNtlmAuth('username', 'firstpass'))
    print (responsee.text)
    if responsee.status_code == 200:
        print("Login successfully")
        response = s.post("url2",params=info)
        print(response.text)
4

0 回答 0