Sign in to follow this  
CzarKirk

Grabbing a CSV via HTTP

Recommended Posts

Hello there. I'm trying to create a C++ program using VC++ Express that can download a file from the internet and extract data from it, using HTTP get. For example, one get URL I am using is http://ichart.finance.yahoo.com/table.csv?s=GOOG&d=10&e=19&f=2008&g=d&a=7&b=19&c=2004&ignore=.csv Where the get parameters can be changed to different companies and dates (it contains stock data) My program can open a locally-saved CSV but I'm having difficulty finding a way to grab files from the internet and use them. I've had a look at different libraries available such as libcurl but they are too complicated and I don't really understand how to use them. I just need something simple and easy to use. Thanks for any advice. :)

Share this post


Link to post
Share on other sites
I have done this before and just used a system call to wget. If you don't know, it is a command line program to download files with a variety of protocols including HTTP. There is a version for windows available here.

Share this post


Link to post
Share on other sites
I would recommend using libcurl, or if you are Windows-only, WinInet.

However, if you want to write your own code, then you can have a look at the source code for the public domain HTTP-GET library. It seems like it would fit your needs perfectly.

Share this post


Link to post
Share on other sites
Why use C++ to solve this problem??

C# or another higher level language can download files in one function call. Not to mention they have much better built-in parsing capabilities..

EDIT: also, if you're doing any kind of Market Data automation process... C# is a much better choice... unless you're doing a real time trading application... trust me I've done them both in C++ and C#, and C# is a walk in the park compared to C++ for this... although, since your data 'vendor' is Yahoo's web site... I somehow doubt this is for serious commercial purposes [grin].

[Edited by - graveyard filla on November 20, 2008 2:26:48 PM]

Share this post


Link to post
Share on other sites
I am open to the idea of using C# if it has such large advantages. As I am completely new to this language however could you direct me to more information about the function call to download info for example. Any other information you think might be useful would be most appreciated. Thanks!

Share this post


Link to post
Share on other sites
Quote:
Original post by CzarKirk
I am open to the idea of using C# if it has such large advantages. As I am completely new to this language however could you direct me to more information about the function call to download info for example. Any other information you think might be useful would be most appreciated. Thanks!



string url = "Your URL here";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
using(HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
Stream str = response.GetResponseStream();
// Read data from stream 'str' and do whatever you want with it.
}


HttpWebRequest and HttpWebResponse are in the System.Net namespace.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this