Results 1 to 21 of 21

Thread: [RESOLVED] Grabbing Images With Webbrowser

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Resolved [RESOLVED] Grabbing Images With Webbrowser

    Hi,
    My prog takes a location the user inputs and searches for a map of that location through a webbrowser. I need to be able to take the image from the webbrowser and show it in a picturebox on my form. The name of the picture will always remain constant but the location is always different. The page where I submit the location the user input is sent is here . Type in 'Sandton' into that first textbox and the map which comes up is the image which I would like to get with my webbrowser into a picturebox.
    Thanx a lot,
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Grabbing Images With Webbrowser

    Take a look at my code examples throughout this thread.

    http://www.vbforums.com/showthread.php?t=330341
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Grabbing Images With Webbrowser

    I already looked at that RobDog888, but I couldnt find out how to take the images with a webbrowser and move them to a Picturebox.
    I expect it will be using the MS HTML Object Library, and then something like
    VB Code:
    1. Dim objhtml as new MSHTML.MSHTMLDocument
    2. Picturebox.Picture = LoadPicture(objhtml.Images(0))
    But that exact code doesnt work, so please explain to me how to do it.
    Thanx,
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Grabbing Images With Webbrowser

    I think you would have to use the Inet control then to download the page and parse out the "<img" or "src=" tags. Then use the Open filename to put the binary picture in a local file and load to a picturebox. This is how I did it before.
    VB Code:
    1. Dim b() As Byte
    2.     Dim sSrc As String
    3.  
    4.     Inet1.URL = "http://www.somepage.com"
    5.     txtImage = Inet1.OpenURL("http://www.somepage.com", icString)
    6.     'Parse the page in txtImage for the src= and place in a var
    7.     '
    8.     'sSrc = parsed path
    9.     '
    10.     b() = Inet1.OpenURL(sSrc, icByteArray)
    11.     Open "C:\MyImage.gif" For Binary As #1
    12.         Put #1, , b()
    13.     Close #1
    14.     imgPicture.Picture = LoadPicture("C:\MyImage.gif")
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Grabbing Images With Webbrowser

    hmm... What is icString, and what is meant to be in sSrc?
    Did you take a look at the link of the image I need to capture?
    Thanx,
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Grabbing Images With Webbrowser

    That code will download the html as a string (icString)
    You will have to parse the filename from the data that is returned, and then download that file (sSrc)

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Grabbing Images With Webbrowser

    icString is a constant that defines the Inet control to open the page as string text. sScr is a variable to hold the parsed image location.

    You could set your browser to navigate to "http://www.maporama.com/affiliates/shellza/share/map.asp?SEARCH_ADDRESS.x=0&COUNTRYCODE=ZA&SESSIONID=6C164693-6C0F-48B5-B3FA-E0FF20B64397&_XgoGCTownName=Sandton&Zip=&_XgoGCAddress=&x=15&y=20" and when the page is completely loaded you can search for the image name/location and then use the Inet control to open that location as Binary and download the image to the temp file and use LoadImage into the picturebox.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Grabbing Images With Webbrowser

    OK thanx guys!
    Now how do I go about parsing the location of that image because it doesnt end in a regular .jpg or .gif extension.
    I really appreciate any help,
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Grabbing Images With Webbrowser

    I dont think your going to be able to do this as the page is an ASP page and the image is rendered only if you have a current valid session variable id initiatedfrom the initial page. Its probably for preventing people from using its images

    This is the location of the map picture and as you can see it has the session variable and other parameters passed to create the image map.

    <td class="2pixBorder"><input type="image" border="0" name="XgoClickMap" align="center" src="../image.asp?XgoPageName=XMLOUT&amp;XgoUserID=1F2A8BEBF4148E4&amp;XgoNbReq=3&amp;XgoAnswer=Gif&amp;size x=370&amp;sizey=263&amp;CODE=lieue" title="Click to recenter" width="370" height="263"></td>
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Grabbing Images With Webbrowser

    Those are dynamic picture names. Here is the one for Sandton.

    I used the DOM Inspector in Firefox and clicked on the image.

    Here's what i found in the source:

    <tr>
    <td class="2pixBorder"><input type="image" border="0" name="XgoClickMap" align="center" src="../image.asp?XgoPageName=XMLOUT&amp;XgoUserID=74642A63405F4107&amp;XgoNbReq=1&amp;XgoAnswer=Gif&amp;siz ex=370&amp;sizey=263&amp;CODE=lieue" title="Click to recenter &amp; zoom in" width="370" height="263"></td>
    <td valign="top" bgcolor="FFC100" class="2pixBorder">
    <table width="100%" height="100" border="0" cellpadding="0" cellspacing="0">
    <tr>
    Attached Images Attached Images  
    Last edited by dglienna; Oct 9th, 2005 at 01:28 PM.

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Grabbing Images With Webbrowser

    Thats the same picture name I posted in #9. I also mentioned its dynamic depending on the sessions variable that is also passed.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Grabbing Images With Webbrowser

    Didn't see it when I started the post. Decided to use the Inspector, and got hung up saving it. Then I used source.

  13. #13
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Grabbing Images With Webbrowser

    11 minutes? Anyways...

    What you can do is use the inet control set to the initial page and populate the city name and submit. Then in the resulting page parse out the session id and save to a variable. Then connect using the inet control again to the image location passing the session id and image parameters. Then Put it to a system file and load to your picturebox control. Not very pretty but it may work.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Grabbing Images With Webbrowser

    OK, I can do that. How will I get the image parameters?
    thnx
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  15. #15
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Grabbing Images With Webbrowser

    Like I posted you need to parse out the properties. you can use Instr and Mid$ and Len to do it. This is the part you want...
    VB Code:
    1. src="../image.asp?XgoPageName=XMLOUT&amp;[b]XgoUserID=[/b]1F2A8BEBF4148E4&amp;[b]XgoNbReq=[/b]3&amp;[b]XgoAnswer=[/b]Gif&amp;[b]sizex=[/b]370&amp;[b]sizey=[/b]263&amp; CODE=lieue" title="Click to recenter" width="370" height="263">
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  16. #16
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Grabbing Images With Webbrowser

    XgoUserID=1F2A8BEBF4148E4 is the session parameter value that will change between runs.
    Not too sure what this one is for: XgoNbReq=3
    This is the image extension: XgoAnswer=Gif
    Image properties: sizex=370&amp;sizey=263&amp;
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  17. #17

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Grabbing Images With Webbrowser

    Thanx a lot RobDog888!
    One last question: what is the absolute location for that ".../image.asp?..."??
    Thanx a lot!
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  18. #18
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Grabbing Images With Webbrowser

    That's the Active Server Page on the webserver. You cannot access it directly, without passing it the other information. You could have your program fill out the first page and click the button though.

  19. #19

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Grabbing Images With Webbrowser

    Yes but once I've rendered the image and gotten the ID of the image what goes before the "..." as the location of where the image.asp page is located
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  20. #20

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: [RESOLVED] Grabbing Images With Webbrowser

    Well the original question has been resolved, thanx!
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  21. #21
    New Member
    Join Date
    May 2007
    Posts
    3

    Re: [RESOLVED] Grabbing Images With Webbrowser

    Is there any way to capture or save dynamic image from a webBrowser control

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width