简体   繁体   中英

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. It appears that the VIEWSTATE data that goes back controls the date that is selected.

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?

I am using c# and WebBrowser controls. I tried a WebRequest / modified POST approach but it didn't work.

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.

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");
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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