Are there any free libraries available for performing HTTP requests and responses?
Are there any free libraries available for performing HTTP requests and responses?
Ah I think libcurl might be useful. I only need it to get the content from a page. It's for a data harvester.
If you only need source you can save it to a file:This works with visual studio. What compiler do you use?Code:#include <stdio.h> #include <string.h> #include <windows.h> #include <urlmon.h> /* Or link to the library via the means you normally would do */ #pragma comment( lib, "urlmon.lib" ) int main() { char url[] = "http://www.google.com"; char sourceFile[MAX_PATH]; HRESULT hr = URLDownloadToCacheFile(0, url, sourceFile, MAX_PATH, 0, 0); if ( hr == S_OK ) { /* Read the file at sourceFile */ printf( "Source located at: %s\n", sourceFile ); } return 0; }
[edit] Sorry, first code I posted was C++
Last edited by twomers; 12-24-2008 at 06:44 AM.
Sorry. Maybe someone else can help.
Though libcurl is easy to work with. And if your 'data harvester' needs to get fancier, ie using cookie manipulation, multi threading, etc, it'll be easier to do it with libcurl than other high level functions, I think.
Moved to Networking/Device Communication forum.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Like jamesjeffery said, libcurl is the way to go. Here's the tutorial.
> You wouldn't happen to have a Linux equivalent for this would you?
Sure, either use libcurl as mentioned above or call `wget`