2017-05-23 90 views
0

試圖抓取網頁。有嵌入式隱藏控件可選擇要返回哪一天的數據。我修改了這個值,修改了文本,修改了發送的POST數據,都無濟於事。看起來返回的VIEWSTATE數據控制着所選的日期。更新viewstate網頁抓取

我試圖改變文本框中的日期值,並調用提交,但這是行不通的。

有沒有辦法找出要調用哪個java腳本來模擬點擊控件,以便更新VIEWSTATE?

我正在使用c#和WebBrowser控件。我嘗試了WebRequest /修改後的POST方法,但沒有奏效。

這是創建日期選擇

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

回答

0

下載的所有文件,個.axd和搜索,直到我發現此控件的set_text方法的代碼。

然後:

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