curl文件仅包含0而不包含html
我试着从google.de获取一些HTML代码,效果很好。 我的printf也会像应该的那样将代码打印到控制台中,但文件只包含“0”,而不包含“hmtl代码”curl文件仅包含0而不包含html,html,c,curl,Html,C,Curl,我试着从google.de获取一些HTML代码,效果很好。 我的printf也会像应该的那样将代码打印到控制台中,但文件只包含“0”,而不包含“hmtl代码” 您只是将返回代码从curl\u easy\u perform写入文件。如果您想保存任何返回的数据,我想您还需要调用optionCURLOPT\u WRITEFUNCTION。@simonc我不明白,您可能有一个例子吗? int main() { CURL *curl; CURLcode res; FILE *fil
您只是将返回代码从
curl\u easy\u perform
写入文件。如果您想保存任何返回的数据,我想您还需要调用optionCURLOPT\u WRITEFUNCTION
。@simonc我不明白,您可能有一个例子吗?
int main()
{
CURL *curl;
CURLcode res;
FILE *file;
file = fopen("/Users/xxx/Desktop/html.txt","a+");
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://www.google.de/search?client=safari&rls=en&q=wetter+paderborn&ie=UTF-8&oe=UTF-8&gws_rd=cr&ei=eNWRUr7xGtPY4QS5rYD4Cw#q=wetter+paderborn&rls…");
res = curl_easy_perform(curl);
printf("%u",res);
fprintf(file,"%u",res);
curl_easy_cleanup(curl);
fclose(file);
}
}