Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- std::string user = "test1015";
- std::string pass = "qwerty123";
- curl_global_init(CURL_GLOBAL_ALL);
- CURL * myHandle;
- CURLcode result; // We’ll store the result of CURL’s webpage retrieval, for simple error checking.
- struct BufferStruct output; // Create an instance of out BufferStruct to accept LCs output
- output.buffer = NULL;
- output.size = 0;
- struct curl_slist *headers = NULL;
- headers = curl_slist_append(headers, "application/x-www-form-urlencoded; charset=UTF-8");
- myHandle = curl_easy_init();
- /* Notice the lack of major error checking, for brevity */
- curl_easy_setopt(myHandle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback); // Passing the function pointer to LC
- curl_easy_setopt(myHandle, CURLOPT_WRITEDATA, (void *)&output); // Passing our BufferStruct to LC
- curl_easy_setopt(myHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
- //curl_easy_setopt(myHandle, CURLOPT_AUTOREFERER, 1);
- curl_easy_setopt(myHandle, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
- curl_easy_setopt(myHandle, CURLOPT_ENCODING, "UTF-8");
- curl_easy_setopt(myHandle, CURLOPT_COOKIEJAR, "cookie.txt");
- curl_easy_setopt(myHandle, CURLOPT_COOKIEFILE, "cookie.txt");
- curl_easy_setopt(myHandle, CURLOPT_POST, TRUE);
- //curl_easy_setopt(myHandle, CURLOPT_FORBID_REUSE, 1); //mimic real world use
- curl_easy_setopt(myHandle, CURLOPT_URL, "http://www.plemiona.pl/index.php?action=login&show_server_selection=0");
- curl_easy_setopt(myHandle, CURLOPT_REFERER, "http://www.plemiona.pl/index.php");
- //
- curl_easy_setopt(myHandle, CURLOPT_HTTPHEADER, headers);
- curl_easy_setopt(myHandle, CURLOPT_POSTFIELDS, "user=test1015&password=qwerty123&cookie=true&clear=true&server=pl84");
- result = curl_easy_perform(myHandle);
- if (result == CURLE_OK){
- //logowanie cd
- result = curl_easy_setopt(myHandle, CURLOPT_URL, "http://www.google.pl");
- if (result == CURLE_OK){
- curl_easy_setopt(myHandle, CURLOPT_REFERER, "http://www.google.pl");
- curl_easy_setopt(myHandle, CURLOPT_POST, TRUE);
- headers = curl_slist_append(headers, "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
- curl_easy_setopt(myHandle, CURLOPT_HTTPHEADER, headers);
- curl_easy_setopt(myHandle, CURLOPT_POSTFIELDS, "user=test1015&password=70d02a81bb359ffbc3d682699c8649e9de97883f");
- curl_easy_perform(myHandle);
- curl_easy_setopt(myHandle, CURLOPT_WRITEDATA, (void *)&output); // Passing our BufferStruct to LC
- FILE * fp;
- fopen_s(&fp, "example12.html", "w");
- if (!fp)
- return 1;
- fprintf(fp, output.buffer);
- fclose(fp);
- if (output.buffer)
- {
- free(output.buffer);
- output.buffer = 0;
- output.size = 0;
- }
- }
- }
- curl_easy_cleanup(myHandle);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement