From the course: Exploring C Libraries

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Fetching a web page

Fetching a web page - C Tutorial

From the course: Exploring C Libraries

Start my 1-month free trial

Fetching a web page

- The libcurl library lets you send or retrieve information to or from the internet in a four step process. First, you initialize the easy curl interface, which returns a curl handle, like a file handle, used to access the data. Second, you set options for the curl handle, which include the URL, data handling, air handling, and so on. Third, you perform the curl operation. And finally, you clean up curl, similar to closing an open file. This code shows the most basic of curl programs which fetches text data from a website. The URL is assigned to a string address at line nine. Libcurl is initialized at line 12, with the results assigned to the curl variable CURL declared at line seven. Now if this variable is null, an error messages output, and the program halts. The only option set is a webpage address by using the curl_easy_setopt function at line 21. Now multiple calls to this function can be made depending on what…

Contents