Rumah  >  Soal Jawab  >  teks badan

网络 - C++使用libcurl下载文件,传入url失败?CURLE_URL_MALFORMAT

...
//get url by parsing xml using rapidxml 
char* url  =  root->first_node("MFC_uri")->value(); //http://xx.com/xx.bin 
printf(url ); //http://xx.com/xx.bin
char outfilename[FILENAME_MAX] = "mfc.bin"

curl = curl_easy_init();
if (curl) 
{
    fp = fopen(outfilename,"wb");
    //curl_easy_setopt(curl, CURLOPT_URL, "http://xx.com/xx.bin"); //OK
    curl_easy_setopt(curl, CURLOPT_URL,url); //NG 
    
    printf(url); //http://xx.com/xx.bin
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
    
    res = curl_easy_perform(curl);  //CURLE_URL_MALFORMAT == 3
    printf("res code %d",res);
    /* always cleanup */
    curl_easy_cleanup(curl);
    fclose(fp);
    printf("done \n");
}
....

直接传入url没有问题,能够正常下载,
但是通过rapidxml,解析xml文件获取url,然后传入url,则不能下载,执行结果CURLE_URL_MALFORMAT,
c++菜鸟,强行上战场,求指教.

*******
自己的锅,解析别人给的xml的时候没有忽略换行符,搞了这么久,居然是这个原因....已经解决了,谢谢SF
*******
阿神阿神2764 hari yang lalu754

membalas semua(0)saya akan balas

Tiada jawapan
  • Batalbalas