使用libcurl发送模仿浏览器的POST请求

时间:2014-12-23 15:38:15

标签: c++ post curl libcurl

我正在尝试将 POST 请求发送到特定网站:

curl_easy_setopt(curl, CURLOPT_URL, web.c_str());
  curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
  curl_easy_setopt(curl, CURLOPT_VERBOSE, true);
  curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
  curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)");
  curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
  res = curl_easy_perform(curl);

网站不会向我显示 POST 请求的结果,我认为这是因为curl请求不像“真正的浏览器”。 有没有更好的方法来制作最能模仿浏览器的卷曲请求? 或者你认为问题是不同的。

0 个答案:

没有答案