簡體   English   中英

使用vb.net閱讀Internet Explorer頁面標題

[英]Read Internet Explorer page title with 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加載,我無法查看源代碼。謝謝。)

ie.Document.title屬性應該具有您所需要的。 http://msdn.microsoft.com/zh-CN/library/ie/ms535862(v=vs.85).aspx

我只是將頁面作為字符串檢索並找到標題:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM