Closed Thread
Results 1 to 5 of 5

Thread: Using winhttp to download images

  1. #1
    harshareddy75 is offline Newbie
    Join Date
    Mar 2010
    Posts
    20
    Rep Power
    0

    Using winhttp to download images

    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

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: Using winhttp to download images

    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 /

  4. #3
    harshareddy75 is offline Newbie
    Join Date
    Mar 2010
    Posts
    20
    Rep Power
    0

    Re: Using winhttp to download images

    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

  5. #4
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: Using winhttp to download images

    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 /

  6. #5
    harshareddy75 is offline Newbie
    Join Date
    Mar 2010
    Posts
    20
    Rep Power
    0

    Re: Using winhttp to download images

    ya i figured yesterday that it is the same as reading a page. Anyhow thanks a lot for your help

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Question about how WinHTTP handle POST request
    By 13thAngel in forum C and C++
    Replies: 0
    Last Post: 05-21-2010, 03:51 PM
  2. Using winhttp to post
    By harshareddy75 in forum C and C++
    Replies: 11
    Last Post: 04-08-2010, 02:09 PM
  3. Using winhttp for decompression
    By harshareddy75 in forum C and C++
    Replies: 2
    Last Post: 03-11-2010, 12:59 AM
  4. Why i need wait long time to download images?
    By mario in forum C# Programming
    Replies: 5
    Last Post: 04-13-2009, 03:52 AM

Tags for this Thread

Bookmarks

Posting Permissions

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