Page 1 of 1

using Webbrowser1.Document to get images?

Posted: Sat Jun 01, 2013 7:40 pm
by GaiaonlineHD
trying to get an image to be set onto a picture box using this
Code: Select all
        WebBrowser1.Document.Images.GetElementsByName("p_icon")
        PictureBox2.ImageLocation = ("p_icon")
but since i dont know what im doing it won work anyhelp on this?

Re: using Webbrowser1.Document to get images?

Posted: Sat Jun 01, 2013 8:51 pm
by comathi
Do you mind sharing the URL to the page you are trying to download the image from?

But just from the info you've provided, here's something that might work:
Code: Select all
Dim images As HtmlElementCollection = WebBrowser1.Document.Images.GetElementsByName("p_icon")
        For Each i As HtmlElement In images
            PictureBox1.ImageLocation = i.GetAttribute("src")
        Next
You could put that in WebBrowser.DocumentCompleted, or in some Button.

Re: using Webbrowser1.Document to get images?

Posted: Sat Jun 01, 2013 9:42 pm
by GaiaonlineHD
comathi wrote:
Do you mind sharing the URL to the page you are trying to download the image from?

But just from the info you've provided, here's something that might work:
Code: Select all
Dim images As HtmlElementCollection = WebBrowser1.Document.Images.GetElementsByName("p_icon")
        For Each i As HtmlElement In images
            PictureBox1.ImageLocation = i.GetAttribute("src")
        Next
You could put that in WebBrowser.DocumentCompleted, or in some Button.
it didnt show up the imaged but, i am also having problems with trying to get the id and inputing the id/value of the id into a textbox. any idea on that. thanks on the other one i will try to tweak it.

Re: using Webbrowser1.Document to get images?

Posted: Sat Jun 01, 2013 9:43 pm
by GaiaonlineHD
GaiaonlineHD wrote:
comathi wrote:
Do you mind sharing the URL to the page you are trying to download the image from?

But just from the info you've provided, here's something that might work:
Code: Select all
Dim images As HtmlElementCollection = WebBrowser1.Document.Images.GetElementsByName("p_icon")
        For Each i As HtmlElement In images
            PictureBox1.ImageLocation = i.GetAttribute("src")
        Next
You could put that in WebBrowser.DocumentCompleted, or in some Button.
it didnt show up the imaged but, i am also having problems with trying to get the id and inputing the id/value of the id into a textbox. any idea on that. thanks on the other one i will try to tweak it.
this is one of them a_createdate from this site. http://quickfind.kassad.in/

Re: using Webbrowser1.Document to get images?

Posted: Sun Jun 02, 2013 8:10 am
by Dummy1912
GaiaonlineHD wrote:
trying to get an image to be set onto a picture box using this
Code: Select all
        WebBrowser1.Document.Images.GetElementsByName("p_icon")
        PictureBox2.ImageLocation = ("p_icon")
but since i dont know what im doing it won work anyhelp on this?

not sure if im correct but to show the image must it not be
Code: Select all
PictureBox2.Image = ("p_icon")
instead of
Code: Select all
 PictureBox2.ImageLocation = ("p_icon")

Re: using Webbrowser1.Document to get images?

Posted: Sun Jun 02, 2013 3:29 pm
by GaiaonlineHD
Dummy1912 wrote:
GaiaonlineHD wrote:
trying to get an image to be set onto a picture box using this
Code: Select all
        WebBrowser1.Document.Images.GetElementsByName("p_icon")
        PictureBox2.ImageLocation = ("p_icon")
but since i dont know what im doing it won work anyhelp on this?

not sure if im correct but to show the image must it not be
Code: Select all
PictureBox2.Image = ("p_icon")
instead of
Code: Select all
 PictureBox2.ImageLocation = ("p_icon")
tried that before.

Re: using Webbrowser1.Document to get images?

Posted: Sun Jun 02, 2013 4:02 pm
by comathi
Here's the code to at least get the a_createdate:
Code: Select all
Dim h2List As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("h2")

        For Each h2 As HtmlElement In h2List
            If h2.GetAttribute("id") = "a_createdate" Then
                MessageBox.Show(h2.InnerText)
            End If
        Next