How do i Download Web Page using C (not with libcurl), OS: Win32
Asked
Active
Viewed 5,909 times
2
-
1What's with this guy asking the same question over and over? – cschol Jan 01 '09 at 17:26
-
@bortzmeyer libcurl is a no-brainer on Linux. However, Windows doesn't come with libcurl. Computer viruses have utilized the `wininet` library for years. – unixman83 Apr 13 '12 at 20:41
3 Answers
4
To download a web page, you need two things:
- Establish a communication channel with the websever
- Manage the web server protocol to download a page.
For the first item, have a look at the socket API. You need to open a socket, send some data using send(), receive data from the webserver.
For the second item, you need to understand the http protocol.
Philippe F
- 11,190
- 5
- 28
- 30
1
What you need to do is called "socket communications". For an excellent overview, check out
http://web.archive.org/web/20090402133256/http://www.uwo.ca/its/doc/courses/notes/socket/
http://wiki.linuxquestions.org/wiki/Connecting_a_socket_in_C
That last link is from linuxquestions, but both solutions are completely cross-platform, as opposed to frankodwyer's suggestion of wininet. The last link also does exactly what you want, in that it downloads a web page.
joe_young
- 3,991
- 2
- 24
- 36
dj_segfault
- 11,701
- 4
- 27
- 35
-
Thanks for dinging me a point, unixman83. I'll be sure and return the favor at some point. You must care a whole lot more than the OP since he asked this question THREE YEARS AGO and didn't select an anser. – dj_segfault Apr 13 '12 at 21:50