#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
#include <errno.h>
#include <curl/curl.h>
using namespace std;
string gettimenow()
{
time_t t = time(0); // get time now
struct tm * now = localtime( & t );
std::ostringstream stm ;
stm << (now->tm_year + 1900)<<"-"
<< (now->tm_mon + 1)<<"-"
<< now->tm_mday<<"-"
<< now->tm_hour<<"-"
<<now->tm_min<<"-"
<<now->tm_sec;
return stm.str();
}
// proxyURL - https://web-proxy.ind.hp.com
//exampleURL - https://example.com
int main()
{
string cmd = "curl -k -x proxyURL:8080 -L exampleURL --connect-timeout 10";
string output ="";
string errorout = "";
int i =0;
while ( i< 50){
cout<< "value i ="<<i<<endl;
cout<<"sss 35 "<<gettimenow()<<endl;
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "EXAMPLEURL");
curl_easy_setopt(curl,CURLOPT_PROXY,"proxyURL");
curl_easy_setopt(curl,CURLOPT_PROXYPORT,8080);
curl_easy_setopt(curl,CURLOPT_PROXYTYPE,CURLPROXY_HTTP);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, false);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10L);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
if(res != CURLE_OK){
cout<<"CURL failed with error ::"<<curl_easy_strerror(res)<<endl;
}else
cout<<"CURL api success "<<endl;
}
sleep(60);
i++;
}
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include