Hi guys,
I have been using winhttp to download pages (openrequest, sendrequest etc.) However I dont know how to download images from these webpages at the same time using winhttp. Is it possible? If it is, could please direct me to the api or post an example?
Thanks
Harsha Reddy
Using winhttp to download images
Started by harshareddy75, Mar 21 2010 11:04 PM
4 replies to this topic
#1
Posted 21 March 2010 - 11:04 PM
|
|
|
#2
Posted 22 March 2010 - 10:59 AM
You're going to need to parse the HTML and look for the <img src=... /> tags. Strip the URL out of that. If it's a fully qualified name (i.e. of the form "http://www.mysite.com/images/some-folder/picture.png"), then you're going to have to open a connection to the other server and download it from there. (You may be able to get your current server to get the file for you, but I've never tried it. I think it requires HTTP 1.1, not sure.) If it's a relative URL like images/some-folder/picture.png then you can download it from the current server.
sudo rm -rf /
#3
Posted 22 March 2010 - 07:26 PM
Hey,
So after getting the connection again to required server, can I just use the winhttpreaddata to get the image ?
Thanks again for the reply.
Regards,
Harsha
So after getting the connection again to required server, can I just use the winhttpreaddata to get the image ?
Thanks again for the reply.
Regards,
Harsha
#4
Posted 23 March 2010 - 10:13 AM
It's the same as reading a webpage, if I recall correctly. You're going to have to look at the Content-Transfer-Encoding and Content-Type headers to check what you got back in case you need to convert it. You're probably going to get some sort of MIME header like image/png or whatever, and the Content-Transfer-Encoding header should be either base64 or 8bit (doubtful but possible).
sudo rm -rf /
#5
Posted 23 March 2010 - 06:55 PM
ya i figured yesterday that it is the same as reading a page. Anyhow thanks a lot for your help


Sign In
Create Account


Back to top









