tags:

views:

171

answers:

7

I was told I have to use winsock, but I dont know where to start. For example, I am trying to access, lets say http://www.newegg.com/, I am trying to get the text title of just the three front page products. Any help is greatly appreciated. :D

A: 

you need to open a socket.

then you need to do an http get

somewhat like :- http://www.esqsoft.com/examples/troubleshooting-http-using-telnet.htm

Keith Nicholas
A: 

You could use the QNetworkAccessmanager class from Qt framework.

Pilgrim
+1  A: 

W3.org themselves provide sample C / C++ librarys for Http requests.

Find them here

Specifically, look for HTTPReq.c

Tim Jarvis
A: 

Use c++ if you must, but it might be a lot less painful to use python.

Look at the Python httplib module for how to set the host you want to pull from etc. Python's available for free for most platforms and is enough like C++ that you can probably learn python a heck of a lot faster than you can learn to write a program controlled browser in c++. Well, maybe that's not true for everyone on this site, but I'll bet it's true for "most" of us. I used to get stock quotes updated in near real time from CNN Money years ago and IIRC it was around 100 lines of python code.

Hotei

Hotei
-1 please read the question next time.
Romain Hippeau
Is OP trying to solve a problem or trying to learn how to solve a problem with a specific tool as a learning exercise? My answer was oriented towards the first choice, perhaps you have information that leads you towards the second. C++ and Python are just tools, with different strengths and weaknesses. I like and use both. If this sounded to you like "python evangelism" then you are mistaken, though I can see how it could be interpreted that way.
Hotei
A: 

I'm assuming you need to use c++ for a reason, such as integration with existing software, otherwise, as per some of the other suggestions, choosing a language with a more convenient framework (eg: scripting language) would be better suited for the task.

If you would like to avoid getting your hands dirty with WINSOCK, or have the need to run on a platform other than windows, you could look at the using the boost asio library.

The following page contains links to simple sync and async http clients: http://www.boost.org/doc/libs/1_37_0/doc/html/boost_asio/examples.html

You can find documentation on the library itself at: http://www.boost.org/doc/libs/1_37_0/doc/html/boost_asio.html

Phil Young
+3  A: 

I'd also recommend libcurl for this sort of thing.

You can use the cURL command line tool to generate sample code as well, which is helpful for experimentation.

bde
+1  A: 

Use boost library and poco. They both provide solutions for network programming. Boost also provide spirit library which you can use for parsing data from websites. Poco libraru also provides NetSSL, crypto solutions.

P.S. boost::spirit is not a library for parsing data from websites, it provides solution for parsing strings ...

Davit Siradeghyan