cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Help.

From: Peter Wullinger <peter.wullinger_at_gmail.com>
Date: Mon, 29 Jan 2007 11:30:03 +0100

2007/1/29, Surya Kiran Gullapalli <suryakiran.gullapalli_at_gmail.com>:
> Thanks for the Info,
> that did work, but how do i code it using libcurl ??
>
> I'm at loss here now. I'll try to find out if there's any solution here.

I assume you are using C. Then the "short version" (without checks
and error handling) should look something like this. This is similar in
other languages, so I hope it helps.

#include <stdio.h>
#include <stddef.h>

#include <curl/curl.h>

#define URL "http://content.icicidirect.com/findsymbolchart.asp"
#define QUERY "Symbol=ICIC"

int
main(void)
{
        CURL *curl;

        curl = curl_easy_init();
        if (curl != NULL) {
                curl_easy_setopt(curl, CURLOPT_URL, URL);
                curl_easy_setopt(curl, CURLOPT_POST, 1);
                curl_easy_setopt(curl, CURLOPT_POSTFIELDS, QUERY);
                curl_easy_perform(curl);

                curl_easy_cleanup(curl);
                return(0);
        } else
                return(1);
}

Note that if you want use more sophisticated queries, you'll need to properly
encode the "QUERY". Also this short fragment outputs to stdout, which is
probably not what you want in the first place; see CURLOPT_WRITEFUNCTION
for this.

Peter
Received on 2007-01-29