#include <stdio.h>
#include <stdlib.h>
#include <curl/curl.h>
int main(int argc,char *argv[])
{
CURL *curl;
CURLcode res;
if(argc != 2)
{
printf("Usage file <url>\n");
exit(1);
}
// 初始化curl
curl = curl_easy_init();
if(curl != NULL)
{
// 设置目标url
curl_easy_setopt(curl,CURLOPT_URL,argv[1]);
// 输出header头部信息
curl_easy_setopt(curl,CURLOPT_HEADER,1);
// 执行操作
res = curl_easy_perform(curl);
// 执行回收资源
curl_easy_cleanup(curl);
}
return 0;
}
c语言curl简单功能实现
最新推荐文章于 2024-04-12 21:47:34 发布