Вот на с++:
Код:
#include <iostream>
#include <string.h>
#include <curl/curl.h>
using namespace std;
static int writer(char *data, size_t size, size_t nmemb,string *buffer)
{
int result = 0;
if (buffer != NULL)
{
buffer->append(data, size * nmemb);
result = size * nmemb;
}
return result;
}
int main()
{
CURL * curl;
CURLcode result;
curl_slist *slist = NULL;
string buffer;
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
slist = curl_slist_append(slist, "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
slist = curl_slist_append(slist, "Accept-Language: ru,en-us;q=0.7,en;q=0.3");
slist = curl_slist_append(slist, "Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7");
slist = curl_slist_append(slist, "Keep-Alive: 300");
slist = curl_slist_append(slist, "Connection: keep-alive");
curl_easy_setopt(curl, CURLOPT_HEADER, 0);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1);
curl_easy_setopt(curl, CURLOPT_ENCODING, "gzip,deflate");
curl_easy_setopt(curl, CURLOPT_COOKIELIST, "");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writer);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "s=Ob0o3fHbPmqLv5W8T7mGH1SLp5ZM7cw4&s_post=cjJfP4UPuGVSnAcSUWhv1YuvnLYPoqwx&tip=CheckCode&tcurl=SomeRef&tcontinue=yes&captcha=капча");
curl_easy_setopt(curl, CURLOPT_USERAGENT,"Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.43 Safari/532.5");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist);
curl_easy_setopt(curl, CURLOPT_REFERER, "тут url страници где находиться форма");
curl_easy_setopt(curl, CURLOPT_URL, "тут URL страници обрабатывающий запрос!");
result = curl_easy_perform(curl);
//в buffer находиться страница ответа
return 0;
}
|