How would I go about grabbing a picture from a web page programaticly..
Example,
I want to grab the chart for kmart's stock prices..
Kmarts stock chart
to be displayed in a picture box...
Thanks in advance for the help..
Rudy
Printable View
How would I go about grabbing a picture from a web page programaticly..
Example,
I want to grab the chart for kmart's stock prices..
Kmarts stock chart
to be displayed in a picture box...
Thanks in advance for the help..
Rudy
You can access the picture using it's full URL
http://chart.yahoo.com/c/1y/k/kmrt.ob.gif
as long as all you want is that picture
Thanks! Thats exactly what I want. How can I save it for later? Or, is it possible to have a picture box direclt linked to the picture?
Thanks again for the help,
Rudy
This isn't exactly VB related, and you should always double check with copyrights and all that good stuff when using a picture from someone else's website. With that in mind, all you really need to do is right-click on the picture and click Save Picture As... or something similar and then it's right there on your machine, ready to be accesssed.
ok, but I want to be able to do it programaticly.. Without user intervention...
Use winsock and preform a basic GET on the address of the image, you then can load the picture into an image.
That's the fun way, if you want to cheat use the webbrowser control and navigate to the image address.
I quite like the UrlDownloadToFile api for this kind of thing :)VB Code:
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _ "URLDownloadToFileA" (ByVal pCaller as Long, _ ByVal szURL as String, _ ByVal szFileName as String, _ ByVal dwReserved as Long, _ ByVal lpfnCB as Long) as Long Public Function DownloadFile(URL as String, _ LocalFilename as String) as Boolean Dim lngRetVal as Long lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0) If lngRetVal = 0 Then DownloadFile = True End Function 'Usage: DownloadFile "http://www.myserver.com/myfile.txt", "c:\myfile.txt"
TomGibbons,
That was perfect! Thanks alot!
Rudy
You're welcome :)