Home > Software engineering >  Libcurl pick big5 code of webpage
Libcurl pick big5 code of webpage

Time:09-19

Recently in learning, libcurl development environment is vs2008 + libcurl lib + unicode
Nonsense not say directly above code

Int _tmain (int arg c, _TCHAR * argv [])
{
The CURL CURL *;
CURLcode res;
The FILE * FPTR;
Struct curl_slist * http_header=NULL;
If ((FPTR=fopen (FILENAME, "w"))==NULL)
{
Fprintf (stderr, "fopen file error: % s \ n", FILENAME);
return -1;
}
curl=curl_easy_init();

if (! The curl)
{
Fprintf (stderr, "curl init failed \ n");
return -1;
}

Curl_easy_setopt (curl, CURLOPT_URL, POSTURL);//url address
Curl_easy_setopt (curl, CURLOPT_POSTFIELDS POSTFIELDS);//post parameter
Curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION write_data);//to perform operations on data returned by the function address
Curl_easy_setopt (curl, CURLOPT_WRITEDATA FPTR);//this is the fourth parameter values write_data
Curl_easy_setopt (curl, CURLOPT_POST, 1); Ask//set non-zero said the operation is post
Curl_easy_setopt (curl, CURLOPT_VERBOSE, 1);//print debugging information
Curl_easy_setopt (curl, CURLOPT_HEADER, 1);//the response headers and together with the corresponding body to write_data
Curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1);//is set to 0, the location response header information
Curl_easy_setopt (curl, CURLOPT_COOKIEFILE, "/Users/zhu/CProjects/curlposttest. Cookies");
Res=curl_easy_perform (curl);
if (res !=CURLE_OK)
{
The switch (res)
{
Case CURLE_UNSUPPORTED_PROTOCOL:
Fprintf (stderr, "do not support agreement, designated by the URL of the head \ n");
Case CURLE_COULDNT_CONNECT:
Fprintf (stderr, "unable to connect to the remote host or agent \ n");
Case CURLE_HTTP_RETURNED_ERROR:
Fprintf (stderr, "HTTP return error \ n");
Case CURLE_READ_ERROR:
Fprintf (stderr, "read a file error \ n");
Default:
Fprintf (stderr, "return values: % d \ n", res);
}
//return -1;
}
Curl_easy_cleanup (curl);
getchar();
return 0;
}

Print the information of the following



But the content of the pick is garbled, below



But access to the web page information is garbled, could you tell me this how to transcoding?? What is the specific code, thank you so much

CodePudding user response:

This,,,, no one? Their top ~!

CodePudding user response:

c + + USES the curl library send HTTPS requests Chinese garbled question


CodePudding user response:

refer to the second floor zgl7903 response:
c + + USES the curl library send HTTPS requests Chinese garbled question



No, I tried, is big5 code

CodePudding user response:

Transcoding don't have to
  • Related