Read a webpage - C++

Started by
6 comments, last by Skibum 20 years, 11 months ago
I''m looking for a way to read a webpage and save it to a file. I would also need to be able to read binary data off of webpages and save it to disk. How can this be done without using MFC on a windows box? Using Visual Studio 6.0 on Win98. -Skibum
Advertisement
Here''s a link containing source code from the book "Winsock 2.0" by Lewis Napper. One of the examples should be grabbing a file from an HTTP server.

http://www.sockaddr.com/ExampleSourceCode.html
One solution is winsock.

I highly recommend Network Programming for Microsoft Windows, Second Edition by Anthony Jones and Jim Ohmund.

Kuphryn
See ACE

- Magmai Kai Holmlor

"Oh, like you''ve never written buggy code" - Lee

[Look for information | GDNet Start Here | GDNet Search Tool | GDNet FAQ | MSDN RTF[L] | SGI STL Docs | STFW | Asking Smart Questions ]

[Free C++ Libraries | Boost | ACE | Loki | MTL | Blitz++ | wxWindows| Spirit(xBNF)]
[Free C Libraries | zlib ]

- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
quote:Original post by kuphryn
I highly recommend Network Programming for Microsoft Windows, Second Edition by Anthony Jones and Jim Ohmund.
Kuphryn


Despite being the most expensive book in the store; it would be much better if the author(s) didn''t assume you...

ALREADY KNEW EVERYTHING!!!

Sorry. I feel I need to make it clear that you shouldn''t try to make the same mistake I did.

If you don''t already know absolutely everything there is to know about networking programming, this book is not for you.

why doesn't anyone mention the obvious one-line-of-code solution?

URLDownloadToFile.

[edited by - niyaw on March 6, 2003 4:23:18 AM]
After successfully calling a GET and retrieving the result does the socket need to be closed? I''m downloading 2 webpages from a server one after another and the second call is giving me an error on the recv with an error of WSAECONNRESET. If, however, I close the socket and open another it works fine.
That''s part of the HTTP protocol, HTTP 1.1 does let you use persistent connections (I forget how to request that), but HTTP 1.0 you''ve got to connect, make your request, the server sends its response, you close the connection. Then you open a new one for the next request and so on.

This topic is closed to new replies.

Advertisement