PDA

View Full Version : C or C++ code to open and read a web page?



tashirosgt
17th November 2004, 12:14 AM
Python has its urllib to open and read web pages. Does anyone know of a simple example that shows how to do this in C or C++ ?

Dog-One
17th November 2004, 01:12 AM
You may want to look here (http://www.cpqlinux.com/memory.html) for some workarounds.

jtang613
17th November 2004, 03:13 AM
Are you trying to retreive web pages from a server or parse HTML?

tashirosgt
17th November 2004, 03:31 PM
I just want to see how to read the data, not parse and display the page.

xorp
17th November 2004, 06:20 PM
I briefly took a look at this library a while back, I think it may contain what
you are looking for.


http://www.w3.org/Library/

jtang613
17th November 2004, 07:20 PM
I just want to see how to read the data, not parse and display the page.

It's just a text file. Treat it as such. If you want extended html functionality try libwww as mentioned above.

rogue
17th November 2004, 07:31 PM
If you want to learn the fundamentals, Beej's Guide to Network Programming (http://www.ecst.csuchico.edu/~beej/guide/net/) will explain POSIX socket programming, and RFC 2616 (http://www.ietf.org/rfc/rfc2616.txt) describes the HTTP standard... the following gives an idea of the plain-text converstaion between client (browser) and server (web site) when fetching a page:



telnet www.google.com 80 [CR/LF]
Trying 64.233.167.104...
Connected to www.google.com.
Escape character is '^]'.
GET / HTTP/1.1 [CR/LF]
Host: www.google.com [CR/LF][CR/LF]

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html
Set-Cookie: PREF=ID=1419ca500e7b105b:TM=1100715011:LM=11007150 11:S=wgU7QYb0rFA5D1n7; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com
Server: GWS/2.1
Content-Length: 1888
Date: Wed, 17 Nov 2004 18:10:11 GMT

<html>
.
.
.
</html>

tashirosgt
22nd November 2004, 03:59 PM
Thanks for the RFC2616 and libwww links. I'm familiar with socket programming and I agree that Beej's page is a good introduction.

vijay1234
16th October 2005, 04:59 PM
Python has its urllib to open and read web pages. Does anyone know of a simple example that shows how to do this in C or C++ ?
could u show the example for it