Question help get text from browser

SecureECS

New member
Joined
Oct 23, 2009
Messages
3
Programming Experience
Beginner
Can anyone please spend a little time and help me with this code
VB.NET:
Private Sub WebBrowser1_DocumentNavigated(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        If Me.WebBrowser1.DocumentText.Contains("Welcome,") = True Then
            Dim MSDNpage As String = WebBrowser1.Document.Body.InnerText
            My.Computer.FileSystem.WriteAllText("C:\pp2.txt", MSDNpage , True)
            Dim StartIndex As Integer = MSDNpage.EndsWith("<h2>Welcome, ")
            Dim EndIndex As Integer = MSDNpage.StartsWith("</h2>")
            Dim name As String = MSDNpage.Substring(StartIndex + 20, EndIndex - StartIndex - 20).Trim

            MessageBox.Show(name)
        End If
    End Sub
what i want is to extract the text placed between "<h2>Welcome, " and "</h2>".

Thx alot
 

SecureECS

New member
Joined
Oct 23, 2009
Messages
3
Programming Experience
Beginner
VB.NET:
            Dim oRead As System.IO.StreamReader
            Dim lineIn As String
            oRead = File.OpenText("C:\pp2.txt")
            While oRead.Peek <> -1
                lineIn = oRead.ReadLine()
                MessageBox.Show(lineIn.IndexOf(" Welcome,"))
            End While
            oRead.Close()

What i wanna do is to see in a MessageBox the line which contains the word "welcome". how can i do that ? using this code i see every line.
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,553
Location
Norway
Programming Experience
10+
what i want is to extract the text placed between "<h2>Welcome, " and "</h2>".
VB.NET:
Dim name As String = Me.WebBrowser1.Document.GetElementsByTagName("h2")(0).InnerText.Substring(9)
 
Top Bottom