• 大小: 47.06MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-29
  • 语言: 其他
  • 标签: Curl  NuGet  VS2015  HTTP  

资源简介

详细说明:https://blog.csdn.net/wangzhejun123/article/details/88075503

资源截图

代码片段和文件信息

// ConsoleApplication2.cpp : 定义控制台应用程序的入口点。
//

#include “stdafx.h“

#include “curl/curl.h“
#include 

using namespace std;

int write_func(char *ptr size_t size size_t nmemb void *userdata)
{
string* buffer = (string*)userdata;
size_t len = size*nmemb;
//  int offset = strlen(buffer);
//  memcpy(buffer + offset ptr len);
//  buffer[len + offset] = 0;
buffer->append(ptr len);
return len;
}

int main()
{
CURL *curl;
CURLcode res;
string retStr;
string url = “www.baidu.com“;
string query = “wd=1&rsv_spt=1&rsv_iqid=0xf93b16e60000e5a0&issp=1&f=8&rsv_bp=1&rsv_idx=2&ie=utf-8&rqlang=cn&tn=baiduhome_pg&rsv_enter=0&inputT=1220&rsv_t=55f9IcE1DOt0k76jnse60S3%2FPuoF7HgCM060D%2B1pYQRaqGaY4rOVI5sB8eJ7qoK%2FaQiz&oq=%2526lt%253BURL%2526gt%253B_%2526lt%253BOULDNT_R%2526gt%253BSOLV%2526gt%253B_HOST&rsv_pq=bdf45c7600064ee4&rsv_sug3=32&rsv_sug1=15&rsv_sug7=100&rsv_sug4=1220“;


curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
if (curl == NULL)
{
return 0;
}
curl_easy_setopt(curl CURLOPT_TIMEOUT 3);
curl_easy_setopt(curl CURLOPT_HTTPGET 1);
url = url.append(“?“).append(query);
curl_easy_setopt(curl CURLOPT_URL url.c_str());
curl_easy_setopt(curl CURLOPT_WRITEFUNCTION write_func);  //设置回调函数
curl_easy_setopt(curl CURLOPT_WRITEDATA &retStr);        //设置写数据
char error[1024];
curl_easy_setopt(curl CURLOPT_ERRORBUFFER error);

res = curl_easy_perform(curl);
cout << retStr.c_str();
curl_easy_cleanup(curl);
getchar();
return 0;
}





 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     81408  2019-03-02 14:13  CurlTest\.vs\CurlTest\v14\.suo

     文件       1569  2019-03-02 13:25  CurlTest\ConsoleApplication1\ConsoleApplication1.cpp

     文件       9644  2019-03-02 14:08  CurlTest\ConsoleApplication1\ConsoleApplication1.vcxproj

     文件       1397  2019-03-02 13:22  CurlTest\ConsoleApplication1\ConsoleApplication1.vcxproj.filters

     文件        222  2019-03-02 14:07  CurlTest\ConsoleApplication1\ConsoleApplication1.vcxproj.user

     文件        240  2019-03-01 13:34  CurlTest\ConsoleApplication1\packages.config

     文件       1594  2019-03-01 13:18  CurlTest\ConsoleApplication1\ReadMe.txt

     文件        223  2019-03-01 13:18  CurlTest\ConsoleApplication1\stdafx.cpp

     文件        234  2019-03-01 13:18  CurlTest\ConsoleApplication1\stdafx.h

     文件        240  2019-03-01 13:18  CurlTest\ConsoleApplication1\targetver.h

     文件       1339  2019-03-02 14:04  CurlTest\CurlTest.sln

     文件   30482432  2019-03-02 14:13  CurlTest\CurlTest.VC.db

     文件       9477  2018-12-11 07:16  CurlTest\packages\curl-vc140-static-32_64.7.53.0\.signature.p7s

     文件       1022  2017-04-10 16:33  CurlTest\packages\curl-vc140-static-32_64.7.53.0\build\native\curl-vc140-static-32_64.targets

     文件    4228058  2019-03-01 13:14  CurlTest\packages\curl-vc140-static-32_64.7.53.0\curl-vc140-static-32_64.7.53.0.nupkg

     文件      98126  2017-02-17 14:10  CurlTest\packages\curl-vc140-static-32_64.7.53.0\lib\native\include\curl\curl.h

     文件      22979  2017-02-17 14:10  CurlTest\packages\curl-vc140-static-32_64.7.53.0\lib\native\include\curl\curlbuild.h

     文件       9198  2017-02-17 14:10  CurlTest\packages\curl-vc140-static-32_64.7.53.0\lib\native\include\curl\curlrules.h

     文件       3132  2017-02-17 14:10  CurlTest\packages\curl-vc140-static-32_64.7.53.0\lib\native\include\curl\curlver.h

     文件       3575  2017-02-17 14:10  CurlTest\packages\curl-vc140-static-32_64.7.53.0\lib\native\include\curl\easy.h

     文件       2121  2017-02-17 14:10  CurlTest\packages\curl-vc140-static-32_64.7.53.0\lib\native\include\curl\mprintf.h

     文件      16534  2017-02-17 14:10  CurlTest\packages\curl-vc140-static-32_64.7.53.0\lib\native\include\curl\multi.h

     文件       1362  2017-02-17 14:10  CurlTest\packages\curl-vc140-static-32_64.7.53.0\lib\native\include\curl\stdcheaders.h

     文件      39129  2017-02-17 14:10  CurlTest\packages\curl-vc140-static-32_64.7.53.0\lib\native\include\curl\typecheck-gcc.h

     文件    3047136  2018-05-15 05:57  CurlTest\packages\curl-vc140-static-32_64.7.53.0\lib\native\libs\x64\static\debug\libcurl.lib

     文件     339968  2018-05-15 05:57  CurlTest\packages\curl-vc140-static-32_64.7.53.0\lib\native\libs\x64\static\debug\libcurl.pdb

     文件    3463134  2018-05-15 05:59  CurlTest\packages\curl-vc140-static-32_64.7.53.0\lib\native\libs\x64\static\release\libcurl.lib

     文件    3005130  2018-05-15 05:57  CurlTest\packages\curl-vc140-static-32_64.7.53.0\lib\native\libs\x86\static\Debug\libcurl.lib

     文件     331776  2018-05-15 05:57  CurlTest\packages\curl-vc140-static-32_64.7.53.0\lib\native\libs\x86\static\Debug\libcurl.pdb

     文件    3318842  2018-05-15 05:58  CurlTest\packages\curl-vc140-static-32_64.7.53.0\lib\native\libs\x86\static\Release\libcurl.lib

............此处省略130个文件信息

评论

共有 条评论