刮asp.net页面时出现EVENTVALIDATION错误 [英] EVENTVALIDATION error while scraping asp.net page

查看:97
本文介绍了刮asp.net页面时出现EVENTVALIDATION错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从此中获取一些值网站.基本上,我需要获得每个城市的区域.我为此使用Python和beautifulsoup.我正在做的是:

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 :

  1. 首先在此页面上获取请求,然后获取__VIEWSTATE和__EVENTVALIDATION进行POST请求,以获取特定州的城市.直到这里工作为止,我正在获取每个州的城市.

  1. 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.

要获取Area,我需要使用新的__VIEWSTATE和__EVENTVALIDATION进行另一次发布,这一次我还需要发送带有其他参数的城市.但是我在这里遇到了错误:

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>

我已经检查了萤火虫中需要发送的每个参数/参数,以获取对应城市的区域,但没有成功.也许对我来说,问题出在__VIEWSTATE或__EVENTVALIDATION.

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.

请帮助我

推荐答案

您必须在一个会话调用中获取并传递__VIEWSTATE__EVENTVALIDATION变量,否则在重新打开与服务器的连接时执行第二个POST调用时它希望已经收到另一个__VIEWSTATE__EVENTVALIDATION

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()
  • 卷曲GET __VIEWSTATE和__EVENTVALIDATION
  • * 此处的一些逻辑*
  • 卷曲POST解析出__VIEWSTATE和__EVENTVALIDATION
  • *这里的一些逻辑*
  • curl_close();
  • curl_init()
  • curl GET __VIEWSTATE and __EVENTVALIDATION
  • *some logics here *
  • curl POST parsed out __VIEWSTATE and __EVENTVALIDATION
  • * some logics here *
  • curl_close();

这篇关于刮asp.net页面时出现EVENTVALIDATION错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆