我在C中使用Curl,但我不想回应网页代码:
CURL *curl;
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, "www.example.com");
curl_easy_perform(curl);
curl_easy_cleanup(curl);
这有什么卷曲选项吗?
答案 0 :(得分:0)
我找到了解决这个问题的好方法:
size_t function(void *ptr, size_t size, size_t nmemb, FILE *stream) {
return fwrite(ptr, size, nmemb, stream);
}
...
FILE *outfile;
outfile = fopen("test", "w");
CURL *curl;
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, "www.example.com");
curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, function);
curl_easy_perform(curl);
curl_easy_cleanup(curl);
您可以在文件中打印html代码,但不要在“控制台”中打印