Webbrowser document complete

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
5 posts Page 1 of 1
Contributors
User avatar
AnoPem
VIP - Donator
VIP - Donator
Posts: 441
Joined: Sat Jul 24, 2010 10:55 pm

Webbrowser document complete
AnoPem
Whenever i use webbrowser1.documentcompleted im adding a string to a listview but it adds the same string 3 times how can i stop it from doing that, the only thing the webbrowser does it to get the title of the website, and also if there is an easier way to do it than using a webbrowser please tell me
https://t.me/pump_upp
User avatar
comathi
Coding God
Coding God
Posts: 1242
Joined: Fri Mar 26, 2010 1:59 pm

Re: Webbrowser document complete
comathi
You could use HTTPWebRequest to get the contents of the document, and then just extract the title from there.
User avatar
AnoPem
VIP - Donator
VIP - Donator
Posts: 441
Joined: Sat Jul 24, 2010 10:55 pm

Re: Webbrowser document complete
AnoPem
comathi wrote:
You could use HTTPWebRequest to get the contents of the document, and then just extract the title from there.
Could you help me out on that ?
https://t.me/pump_upp
User avatar
comathi
Coding God
Coding God
Posts: 1242
Joined: Fri Mar 26, 2010 1:59 pm

Re: Webbrowser document complete
comathi
Code: Select all
Try
Dim request As Net.HttpWebRequest = Net.HttpWebRequest.Create("http://www.codenstuff.com/forum/home.php")
        Dim response As Net.HttpWebResponse = request.GetResponse
        Dim stream As IO.Stream = response.GetResponseStream
        Dim reader As New IO.StreamReader(stream)
        Dim content As String = reader.ReadToEnd
        Dim lowerContent As String = content.ToLower()
        Dim startIndex As Integer = lowerContent.IndexOf("<title>") + 7
        Dim stopIndex As Integer = lowerContent.IndexOf("</title")

        Dim title As String = content.Substring(startIndex, stopIndex - startIndex)
        Label1.Text = title
Catch ex As Exception
        MsgBox(ex.ToString())
End Try
If you need help using the code, I'd be glad to lend you a hand in TeamViewer ;)
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Webbrowser document complete
mandai
AnoPem wrote:
Whenever i use webbrowser1.documentcompleted im adding a string to a listview but it adds the same string 3 times how can i stop it from doing that
You could just check and set a variable during the DocumentComplete event so it only adds the string once.
5 posts Page 1 of 1
Return to “Coding Help & Support”