2

How do i Download Web Page using C (not with libcurl), OS: Win32

Qantas 94 Heavy
  • 15,750
  • 31
  • 68
  • 83
Question
  • 1,419
  • 3
  • 14
  • 6
  • @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 Answers3

4

To download a web page, you need two things:

  1. Establish a communication channel with the websever
  2. 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,776
  • 5
  • 29
  • 30
3

Try the wininet API

frankodwyer
  • 13,948
  • 9
  • 50
  • 70
1

What you need to do is called "socket communications". For an excellent overview, check out

http://web.archive.org/web/20090227031327/http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_15.html

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
  • 4,107
  • 2
  • 27
  • 38
dj_segfault
  • 11,957
  • 4
  • 29
  • 37
  • 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