rsolo__
rsolo__

Reputation: 29

Read Internet Explorer page title with vb.net

I have this code

    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

However, I need to know the title of this html page. (This page is loaded by javascript and I cannot view the source code. Thanks.)

Upvotes: 0

Views: 1195

Answers (2)

rheitzman
rheitzman

Reputation: 2297

I would just retrieve the page as a string and find the Title:

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

Upvotes: 0

EricLaw
EricLaw

Reputation: 57075

The ie.Document.title property should have what you need. http://msdn.microsoft.com/en-us/library/ie/ms535862(v=vs.85).aspx

Upvotes: 1

Related Questions