问题
I need to get some values from this website. Basically I need to get the Area for every city. I am using Python and beautifulsoup for this. What I am doing is :
First making a Get request to this page and getting __VIEWSTATE AND __EVENTVALIDATION to make a POST request to get cities for a particular state.Till here its working and I am getting cities for every states.
To get Area I need to make another POST with new __VIEWSTATE AND __EVENTVALIDATION and this time i need to send city as well with other parameters.But I am getting error here:
505|error|500|Invalid postback or callback argument. Event validation is enabled using <pages enableeventvalidation="true"> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.|</pages>
I have checked each and every argument/parameter in firebug that I need to send to get areas for corresponding cities but no success. Maybe according to me problem is with __VIEWSTATE or __EVENTVALIDATION.
please help me
回答1:
you have to get and pass the __VIEWSTATE
and __EVENTVALIDATION
variables in one session call, otherwise when doing the second POST call while reopening connection to the server it expects to receive back already another __VIEWSTATE
and __EVENTVALIDATION
!
So basically the logics should be as follows:
- curl_init()
- curl GET __VIEWSTATE and __EVENTVALIDATION
- *some logics here *
- curl POST parsed out __VIEWSTATE and __EVENTVALIDATION
- * some logics here *
- curl_close();
回答2:
Try to add __REQUESTDIGEST
form field, it is a validation field used by Sharepoint.
Also, add name of the select element with states as the value of __EVENTTARGET
field:
__EVENTTARGET ctl00$ctl25$g_4828177f_5427_4b0f_a968_ad02dc3674ec$ctl01$ddlState
__REQUESTDIGEST 0xDF6A6E14C550004C4A8533A9F5D...,14 Jun 2012 10:13:34 -0000
来源:https://stackoverflow.com/questions/11030460/eventvalidation-error-while-scraping-asp-net-page