Howard May Howard May - 9 months ago 79
HTTP Question

Programmatically reading a web page

I want to write a program in C/C++ that will dynamically read a web page and extract information from it. As an example imagine if you wanted to write an application to follow and log an ebay auction. Is there an easy way to grab the web page? A library which provides this functionality? And is there an easy way to parse the page to get the specific data?


Have a look at the cURL library:

 #include <stdio.h>
 #include <curl/curl.h>

 int main(void)
   CURL *curl;
   CURLcode res;

   curl = curl_easy_init();
   if(curl) {
     curl_easy_setopt(curl, CURLOPT_URL, "");
     res = curl_easy_perform(curl);
      /* always cleanup */
   return 0;

BTW, if C++ is not strictly required. I encourage you to try C# or Java. It is much easier and there is a built-in way.