-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetpage.cpp
More file actions
41 lines (36 loc) · 1.04 KB
/
getpage.cpp
File metadata and controls
41 lines (36 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "getpage.h"
/*
#include <iostream>
#include <string>
#include <curl/curl.h>
using namespace std;
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
((string*)userp)->append((char*)contents, size *nmemb);
return size * nmemb;
}
*/
using namespace std;
string Getpage::request_page( const char* destination, string* data)
{
CURL *curl = curl_easy_init();
CURLcode res;
string readBuffer;
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, destination);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data->c_str());
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, data->length());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
res = curl_easy_perform(curl);
//curl_easy_cleanup(curl);
}
return readBuffer;
}
int Getpage::main(int argi, char* url_string[])
{
string result = "points=2048×tamp=03122016";
string ans = request_page(url_string[1], &result);
std::cout << ans << std::endl;
return 0;
}