I'm building an application which I'd like to have it connect to a website and parse some data off it. I'm wondering if anyone could provide me some raw example code.
I don't necessarily need help parsing, I'm just wondering in C++ how would I go about downloading the data from the page into my app so that I can start parsing the data I need out of it?
Check out libCurl.
Check out boost.asio [examples].
Related
So I am using QTCreator (5.0/5.1) and I am trying to access a website in a way that allows me to access information.
I have built a gui (as this is faily easy) but I want to know how to go about connecting to a network in c++ for my first time.
so for example:
https://btc-e.com/api/2/btc_usd/ticker
I want to get all the information present to me there and store it, the parse it, I just don't know how to connect, to the site.
someone mentioned using the #include but I'm not sure how exactly to use it as well.
If you could provide an example that would be great!
Thanks!
For this kind of task you probably want to use the more high level Qt classes to retreive the page and parse the data. Qt provides classes for both HTTP retrieval and parsing JSON data.
Network Programming with Qt
JSON Support in Qt
Read over those documents, have an attempt at writing some code, then ask specific questions, giving the example code you've tried using and what results you're getting.
I want to build a simple chat session between two users, not more. I know that this should be done using socket programming, but to be honest i haven't worked in this domain yet so this will be my first.
I need to know where to start from and was wondering if there are any samples that you suggest i start from.
Thanks in advance.
If you are using Windows, then I would suggest looking at this site to learn the WinSock API.
http://tangentsoft.net/wskfaq/
Section 6.1 contains some example code which I found very helpful when first learning socket programming.
Start by designing the protocol and basic layout. Will the two clients connect to each other directly? Will there be a server involved? Will the clients be specific software? Or will they be browsers? Will they communicate with raw binary data? Or will it be text? Or XML?
Pretty much every socket programming library has a simple chat example. Find one and adapt it to your needs.
Qt is usually friendly to newbies, it has a lot of examples, reference, and users who discuss it.
What to learn to be able to send files online using c++ on windows ?
i know c++, and i got a program that does some benchmark and saves into a text file, i want that text file to be sent to me after the benchmarking is done, so what should i search for ? tried searching found something called sockets and something about server and clients in linux, kinda dunno what to search for.
this isn't a homework, just want to do it for fun xD, and would help me in future if i want someone who knows nothing about whats happening to test something for me (the file would have all i need and it will be sent to me).
I think you better off just emailing the file after a benchmark is done, and doing it using some bash or Python scripting rather than C++ or any other low level language. Here is an example of sending email using Python. Another option would be to upload to the FTP or use rsync to transfer file over SSH. And in any case, do not write your own client-server application for this.
If you still want to use C++, here is an example of sending email using POCO.
you will find some official documentation on Win32 sockets here:
http://msdn.microsoft.com/en-us/library/ms738545%28v=vs.85%29.aspx
This tutorial seems pretty good and simple:
http://johnnie.jerrata.com/winsocktutorial/
Have a nice day!
How do I get form data from HTML page using c++, as far as the basics of post and get?
EDIT: CGI is using apache 2 on windows, I got c++ configured and tested with with apache already.
The easiest way to access form data from an HTTP request is via CGI. This involves reading environment variables which is done using the getenv function.
First of all take a look at webtoolkit.
You might want to use that to make your life easier.
Second you can read about network protocols.
Third take a look at your webserver docs, they might provide such interface to create a deamon that will allow you to read the HTTP socket and the data that is sent over it.
On another note next time you write a question try to elaborate as much as possible.
Explain the use case and provide a test case.
You may use CgiCC library that gives you want you are looking for. You may also try some C++ web framework like CppCMS.
Can someone give me an example of a Unmanaged C++ HTML Client with proxy support?
I want to do some get and posts inside my unmanaged c++ programs, ideally I would like to allow for proxy server configuration, or just use the IE defaults.
I am not looking for hand outs, just something to go by, as I can't seem to find too much on this.
What, seriously?
Call WinHttpGetIEProxyConfigForCurrentUser to get the proxy configuration and then use the HTTP stack of your choice. I would avoid implementing your own psuedo HTTP stack, getting it right is more work then you probably think.
I'd start with Boost.ASIO. It does not deliver out-of-the-box what you request, there are more complete libraries out there, it just happens that I don't know them.
If you're developing on Windows, you can use WinHttp to write a C++ HTTP client, I just finished implementing a client with it here at work.
WinHttp is a fairly straightforward API to use and takes care of all the HTTP communication details for you.