using Webbrowser1.Document to get images?

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.
7 posts Page 1 of 1
Contributors
User avatar
GaiaonlineHD
Member
Member
Posts: 40
Joined: Mon Jan 23, 2012 8:51 pm

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?
User avatar
comathi
Coding God
Coding God
Posts: 1242
Joined: Fri Mar 26, 2010 1:59 pm

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.
User avatar
GaiaonlineHD
Member
Member
Posts: 40
Joined: Mon Jan 23, 2012 8:51 pm

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.
User avatar
GaiaonlineHD
Member
Member
Posts: 40
Joined: Mon Jan 23, 2012 8:51 pm

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/
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

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")
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
GaiaonlineHD
Member
Member
Posts: 40
Joined: Mon Jan 23, 2012 8:51 pm

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.
User avatar
comathi
Coding God
Coding God
Posts: 1242
Joined: Fri Mar 26, 2010 1:59 pm

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
7 posts Page 1 of 1
Return to “Coding Help & Support”