我尝试从google.de获取一些HTML代码,这很好用。 另外我的printf将代码打印到控制台中,但文件只包含“0”而不是“hmtl代码”。
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);
}
}