cURL / Mailing Lists / curl-library / Single Mail

curl-library

Function to return the body of a page?

From: VanL <vlindberg_at_verio.net>
Date: Wed, 13 Mar 2002 12:12:14 -0700

Hello,

I am trying to use libcurl to communicate between some programs.
 Simple.c appears to be mostly what I need, I was just going to pass in
a char * that contained the URL of the two computers I will need to get
info from.

What I can't see in simple, though, is where curl puts the information
after it is retrieved. I'm probably just blind, but I don't see it
writing it anywhere, or putting it in a buffer.

Is there a way to modify simple so that it returns the body of the page
as a string?

For example:

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

int main(void)
{
  pagebody = curl_get_info("http://127.0.0.1:50002");
  printf "%s" % pagebody;
  return 0
}

char curl_get_info(char * URL)
{
  CURL *curl;
  CURLcode res;

  curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_URL, URL);
    res = curl_easy_perform(curl);
    
    pagebody = ?????

    /* always cleanup */
    curl_easy_cleanup(curl);
  }
  return pagebody;
}

Also, can you reuse the same handle repeatedly? for 1..100, get this
url? Or do you need to init and cleanup every time?

Thanks in advance,

VanL
Received on 2002-03-13