Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically reading a web page

Tags:

c++

c

http

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?

like image 269
Howard May Avatar asked Dec 23 '08 15:12

Howard May


People also ask

How to read web page in c#?

Reading a web page with RestSharp We install the RestSharp package. using RestSharp; var client = new RestClient("http://webcode.me"); var request = new RestRequest(); var res = await client. ExecuteGetAsync(request); Console. WriteLine(res.

How do you call a webpage in Java?

Here's a basic example: URL url = new URL("http://www.stackoverflow.com"); URLConnection urlConnection = url. openConnection(); InputStream result = urlConnection. getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(result)); String line = null; while ((line = reader.

What is meant by a web page?

web page. A document which can be displayed in a web browser such as Firefox, Google Chrome, Opera, Microsoft Internet Explorer or Edge, or Apple's Safari. These are also often called just "pages." website. A collection of web pages which are grouped together and usually connected together in various ways.


1 Answers

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, "curl.haxx.se");      res = curl_easy_perform(curl);       /* always cleanup */     curl_easy_cleanup(curl);    }    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.

like image 125
Gant Avatar answered Oct 09 '22 10:10

Gant