I am making requests to a website created using Asp.Net. I am using a Python Requests session to get the __VIEWSTATE
and __EVENTVALIDATION
variables and add them back to the data payload.
response = s.get(url, headers=headers)
soup = BeautifulSoup(response.content, 'lxml')
viewstate = soup.find(id='__VIEWSTATE').get('value')
eventvalidation = soup.find(id='__EVENTVALIDATION').get('value')
payload.update({'__VIEWSTATE': viewstate, '__EVENTVALIDATION': eventvalidation})
session.post(url, headers=headers, data=payload)
This code works great until I do an action on the form that has an onchange
of javascript:setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$Chooser$Segment\',\'\')', 0)
. I have to perform this on a few input
's so there are multiple eventTarget
.
When I modify any form element that is attached to __doPostBack()
function, I receive message of:
Invalid postback or callback argument
from Asp.Net.
How do I simulate multiple __doPostBack
's so my __VIEWSTATE
and __EVENTVALIDATION
do not return an error?