2013-07-22 24 views
0

閱讀的Internet Explorer網頁的標題我有這樣的代碼與vb.net

Dim shellWindows = New SHDocVw.ShellWindows 
    Dim strTemp As String 
    For Each ie As SHDocVw.InternetExplorer In shellWindows 
      If ie.LocationURL = "Http:\\somelocation" then 
        ie.Document.ExecCommand("SelectAll", True, vbNull) 
        ie.Document.ExecCommand("Copy", False, vbNull) 
        strTemp = (Clipboard.GetText()) 
      End if 
    Next 

不過,我需要知道這個HTML頁面的標題。 (本頁面已被JavaScript加載,我無法查看源代碼。謝謝。)

回答

0

我只想檢索頁面爲一個字符串,找到標題:

Imports System.Net 
Imports System.Text 
... 
    Dim myRequest As HttpWebRequest 
    Dim myResponse As HttpWebResponse 
.... 
     myRequest = CType(WebRequest.Create(URL), HttpWebRequest) 
     myResponse = CType(myRequest.GetResponse(), HttpWebResponse) 
     sr = New StreamReader(myResponse.GetResponseStream()) 
     sResponse = sr.ReadToEnd.ToString 
+0

這並不在他所描述的場景中工作,因爲JavaScript的不會跑。 – EricLaw