简体   繁体   English

更新viewstate网站抓取

[英]Updating viewstate web scraping

Trying to scrape a web page. 尝试抓取网页。 There are embedded hidden controls that select which day's data to return. 有嵌入的隐藏控件,用于选择要返回哪一天的数据。 I have modified the value, modified the text, modified the POST data being sent, all to no avail. 我修改了值,修改了文本,修改了要发送的POST数据,但都无济于事。 It appears that the VIEWSTATE data that goes back controls the date that is selected. 似乎返回的VIEWSTATE数据控制了选择的日期。

I tried to change the date value in the text box and invoked submit but that isn't working. 我试图在文本框中更改日期值,并调用了提交,但这不起作用。

Is there a way to figure out what java script to invoke to simulate a click on the control so the VIEWSTATE will be updated? 有没有办法找出要调用哪个Java脚本来模拟对控件的单击,以便VIEWSTATE将被更新?

I am using c# and WebBrowser controls. 我正在使用c#和WebBrowser控件。 I tried a WebRequest / modified POST approach but it didn't work. 我尝试了WebRequest /修改后的POST方法,但是没有用。

This is the code that creates the date selector 这是创建日期选择器的代码

Sys.Application.add_init(function () {
    $create(Infragistics.Web.UI.WebDatePicker, { "id": 
    "ctl00_WebSplitter1_tmpl1_ContentPlaceHolder1_dtePickerBegin", "name": 
    "ctl00_WebSplitter1_tmpl1_ContentPlaceHolder1_dtePickerBegin", "props": 
    [[[], { "c": { "prop1": "[\"2017-4-23-0-0-0-0,,\",\"04/08/03\",\"*0322\",\"04/08/03\",29,0,\"_ig_def_dp_cal\",\"\",\"500,3,300,3,0,200,3,100,3,0\
    "]", 
    "prop": "1,64,,0,1,1,,,0,,,,,6,,200,,2038:2040:2032,igte_NautilusFocus,igte_NautilusHover,igte_NautilusNullText,igte_NautilusInnerFocus,igte_NautilusInnerHover", "uid": "ctl00$WebSplitter1$tmpl1$ContentPlaceHolder1$dtePickerBegin", "buts": "igte_NautilusButtonHover,igte_NautilusButtonPressed,igte_NautilusButtonDisabled,igte_NautilusButtonFocus,../ig_res/Nautilus/images/igte_customHover.gif,../ig_res/Nautilus/images/igte_customPress.gif,../ig_res/Nautilus/images/igte_customDisable.gif," } }], , , []] }, null, null, $get("ctl00_WebSplitter1_tmpl1_ContentPlaceHolder1_dtePickerBegin"));
    });

Downloaded all the .axd files and searched until I found a set_text method for this control. 下载所有.axd文件并进行搜索,直到找到该控件的set_text方法。

Then: 然后:

string szJava = string.Empty;
szJava = "a = $find(\"ctl00_WebSplitter1_tmpl1_ContentPlaceHolder1_dtePickerBegin\"); a.set_text(\"5/20/2017\");";
object a = wb.Document.InvokeScript("eval", new object[] { szJava });
if (webDatePicker != null)
    webDatePicker.InvokeMember("submit");

HtmlElement button = wb.Document.GetElementById("ctl00$WebSplitter1$tmpl1$ContentPlaceHolder1$HeaderBTN1$btnRetrieve");
if (button != null)
{
     button.InvokeMember("click");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM