Код:
#include <stdio.h>
#include <curl/curl.h>
#include <curl/curl.h>
#include <curl/easy.h>
#include <curl/types.h>
size_t write_data_balance(void *buffer, size_t size, size_t nmemb, void *userp);
int main(void)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1 );
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data_balance);
curl_easy_setopt(curl, CURLOPT_URL, "http://it.com.mk");
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
return 0;
}
size_t write_data_balance(void *buffer, size_t size, size_t nmemb, void *userp)
{
char *response;
response = (char*)buffer;
printf("*********** %.*sn",size*nmemb,response);
return size * nmemb;
}
За да ви работи програмава ви треба curl библиотеката
Излез:
kosta@kosta-laptop:~/Desktop/curl-7.17.0$ ./connect
* About to connect() to it.com.mk port 80
* Trying 69.89.25.158... * connected //Blue host
* Connected to it.com.mk (69.89.25.158) port 80
> GET / HTTP/1.1
Host: it.com.mk
Accept: */*
< HTTP/1.1 302
< Date: Mon, 29 Oct 2007 02:20:46 GMT
< Server: Apache/1.3.39 (Unix) mod_fastcgi/2.4.2 mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 FrontPage/5.0.2.2635.SR1.2 mod_ssl/2.8.30 OpenSSL/0.9.7a PHP-CGI/0.1b
< X-Powered-By: PHP/4.4.7
< Location: http://it.com.mk/forum/
< Transfer-Encoding: chunked
< Content-Type: text/html
***********
/* tuka ima uste info ali dosta e ova */
* Closing connection #0