get the picture from WebBrowser?

TMTakas

Member
Joined
Feb 6, 2013
Messages
15
Programming Experience
Beginner
Hi guys

I want a way to get the picture.I mean loaded on your computer

VB.NET:
[COLOR=#000000][FONT=Consolas]<img alt="USA Free VPN Account" src="www.awebsite.com/Imagename.gif" style="margin-bottom: -3px;">

[/FONT][/COLOR]

I've written code but of no value useful

VB.NET:
Dim tooms As String
 
   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click        If RadioButton1.Checked = True Then




            WebBrowser1.Navigate("http://www.[COLOR=#000000][FONT=Consolas]awebsite[/FONT][/COLOR].com/")
            Do Until WebBrowser1.ReadyState = WebBrowserReadyState.Complete
                Application.DoEvents()


            Loop






            Dim allelements As HtmlElementCollection = WebBrowser1.Document.All
            For Each webpageelement As HtmlElement In allelements
                ListBox1.Items.Add(webpageelement.GetAttribute("src"))


            Next




            For Each myString As String In ListBox1.Items


                If myString.Contains("[COLOR=#000000][FONT=Consolas]Imagename[/FONT][/COLOR]") Then
                    ListBox1.SelectedItem = myString


                    tooms = myString
                    Label4.Text = tooms


                    Exit For
                End If


            Next


        End If


    End Sub
End Class
 
Get rid of that Do loop for a start. Call Navigate and be done with it. You then handle the DocumentCompleted event and use the completed document in that event handler. Once you have the image URL, you can use WebClient.DownloadFile or .DownloadData, depending on what you need.
 
Back
Top