I am trying to submit a POST request to pwreset.seattleu.edu/change.aspx
so I can change my account password on the command line. I think that I have set up the request properly, after reading various other similar questions, but the response being returned is the exact same page and my password is not being changed. A valid response should redirect me to pwreset.seattleu.edu/change_success.aspx
Code
from bs4 import BeautifulSoup
import requests
pwreset_url = "https://pwreset.seattleu.edu/change.aspx"
headers = {
'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17',
'Content-Type': 'application/x-www-form-urlencoded',
'Accept-Encoding': 'gzip,deflate,sdch',
'Accept-Language': 'en-US,en;q=0.8',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'
}
session = requests.Session()
session.headers.update(headers)
form_response = session.get(pwreset_url, headers=headers)
soup = BeautifulSoup(form_response.content)
viewstate = soup.find('input', {'name': "__VIEWSTATE"})['value']
viewstategenerator = soup.find('input', {'name': "__VIEWSTATEGENERATOR"})['value']
item_request_body = {
'VIEWSTATE': viewstate,
'VIEWSTATEGENERATOR': viewstategenerator,
'__VIEWSTATEENCRYPTED': '',
'Username': 'my_username',
'OldPassword': 'my_password',
'NewPassword': 'new_password',
'ConfirmPassword': 'new_password',
'DoChg': 'Change Password >>'
}
response = session.post(url=pwreset_url, headers=headers, data=item_request_body)
print(BeautifulSoup(response.content))
Am I doing anything wrong?