2012-11-07 44 views

回答

0

我能夠做到這一點richard's.JHTTPableRowCollection是從HTMLTable留下的小事。 我的代碼是像下面

 object o = null; 
     InternetExplorer ie = new InternetExplorerClass(); 
     IWebBrowserApp wb = ie; 
     wb.Visible = chkShowBrowser.Checked; 
     wb.Navigate("http://LoginPage.aspx", ref o, ref o, ref o, ref o); 

     do 
     { 
      Thread.Sleep(10000); 
     } while (wb.Busy); 

     if (ie.Document != null) 
     { 
      var myDoc = ie.Document as HTMLDocument; 

      if (myDoc != null) 
      { 
       var oUserName = (HTMLInputTextElement)myDoc.getElementById("ctl00_MainBodyPlaceholder_PublicPortalLogin_UserName"); 
       oUserName.value = ConfigurationManager.AppSettings.Get("userName"); 

       var oPassword = 
        (HTMLInputTextElement) 
        myDoc.getElementById("ctl00_MainBodyPlaceholder_PublicPortalLogin_Password"); 
       oPassword.value = ConfigurationManager.AppSettings.Get("password"); 

       var btnSubmitLogin = 
        (HTMLInputElement)myDoc.getElementById("ctl00_MainBodyPlaceholder_PublicPortalLogin_Login"); 
       btnSubmitLogin.click(); 

       do 
       { 
        Thread.Sleep(10000); 
       } while (wb.Busy); 


       if (ie.Document != null) 
       { 
        wb.Navigate("http://SearchPage.aspx", ref o, ref o, ref o, ref o); 


        do 
        { 
         Thread.Sleep(10000); 
        } while (wb.Busy); 



        if (ie.Document != null) 
        { 

         var oIncidentNumber = 
          (HTMLInputTextElement) 
          myDoc.getElementById("ctl00_MainBodyPlaceholder_txtIncidentNumber"); 
         oIncidentNumber.value = ConfigurationManager.AppSettings.Get("incidentNumber"); 

         var btnTicketNumberSearch = 
          (HTMLInputElement)myDoc.getElementById("ctl00_MainBodyPlaceholder_btnSearch"); 
         btnTicketNumberSearch.click(); 

         do 
         { 
          Thread.Sleep(10000); 
         } while (wb.Busy); 

         HTMLTable searchResultTable = myDoc.getElementById("ctl00_MainBodyPlaceholder_gdView_DXMainTable") as HTMLTable; 



         if (searchResultTable != null) 
         { 
          //foreach (var VARIABLE in searchResultTable.T) 
          //{ 

          //} 
         } 

         if (chkRenderBody.Checked) 
         { 
          txtFinalTextBox.Text = myDoc.body.outerHTML; 
         } 
        } 
       } 
      } 
     } 
+0

如何以接受一個評論作爲答案在stackoverflow中關閉該問題? –

1

如果要颳去現有的網頁數據,考慮HtmlAgilityPack

+0

我正在尋找MSHTML和SHDOCVW解決方案。你的帖子有助於提醒它。我需要一個mshtml/sHdocvw解決方案,只需將數據放入某個登錄字段,然後調用某個按鈕的某個單擊事件。然後在新頁面中閱讀htmldom。 –