使用libcurl下载https地址的文件
使用libcurl下载https地址的文件
void downLoadFile(std::string filename, std::string newFilename)
{
CURL *curl_handle;
static const char *pagefilename = (char *)newFilename.data();
FILE *pagefile;
char *p = (char *)filename.data();
curl_global_init(CURL_GLOBAL_ALL); /* init the curl session */
curl_handle = curl_easy_init(); /* set URL to get here */
curl_easy_setopt(curl_handle, CURLOPT_URL, p); /* Switch on full protocol/debug output while testing */
curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L); /* disable progress meter, set to 0L to enable and disable debug output */
curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L);
/* google.com is redirected, so we tell LibCurl to follow redirection */
curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L);
/* SSL Options */
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, );
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, ); /* Provide CA Certs from http://curl.haxx.se/docs/caextract.html */
curl_easy_setopt(curl_handle, CURLOPT_CAINFO, "ca-bundle.crt");
/* send all data to this function */
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data); /* open the file */
pagefile = fopen(pagefilename, "wb");
if (pagefile) { /* write the page body to this file handle */
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, pagefile); /* get it! */
curl_easy_perform(curl_handle); /* close the header file */
fclose(pagefile);
} /* cleanup curl stuff */
curl_easy_cleanup(curl_handle); return ;
}
static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
{
size_t written = fwrite(ptr, size, nmemb, (FILE *)stream);
return written;
}

下载https地址的qq.exe程序
如果有朋友不想编译,我也把我编好的库和lib头文件打包,https://files.cnblogs.com/files/nightnine/libcurl.zip
使用libcurl下载https地址的文件的更多相关文章
- web服务,下载https链接的文件,提示javax.net.ssl.SSLKeyException: RSA premaster secret error
问题: 在服务器上,下载https的链接文件,报错javax.net.ssl.SSLKeyException: RSA premaster secret error 在本地运行的时候没报错,但是在 ...
- Delphi/XE2 使用TIdHttp控件下载Https协议服务器文件[转]
之前的一篇博文详细描述了使用TIdhttp控件下载http协议的文件,在我项目的使用过程中发现对于下载Https协议中的文件与Http协议的文件不同,毕竟Https在HTTP协议基础上增加了SSL协议 ...
- 使用libcurl下载文件小例
libcurl是一个很强大的开源网络处理库,支持包括HTTP.HTTPS.FTP……一系列网络协议.用它来进行HTTP的get\post 或者下载文件更是小菜一碟,chrome内核都用到了它,本文主要 ...
- 使用CInternetSession CHttpFile下载网页链接地址的文件
思路很清晰,使用CInternetSession创建CHttpFile对象.然后对该对象获取文件信息.进行文件读写操作均可. void DownloadFile(LPCTSTR szURL, LPCT ...
- Java下载https文件上传到阿里云oss服务器
Java下载https文件上传到阿里云oss服务器 今天做了一个从Https链接中下载音频并且上传到OSS服务器,记录一下希望大家也少走弯路. 一共两个类: 1 .实现自己的证书信任管理器类 /** ...
- 引用WCF地址报下载“https://xxx:8004/TerminalHandler.svc?disco”时出错问题
服务发布了wcf服务后,在客户端引用发现出现以下错误 - 来自“DISCO 文档”的报告是“下载“https://servername:8004/TerminalHandler.svc?disco”时 ...
- 使用curl,libcurl访问Https
编译curl,libcurl 下载curl源码(git clone https://github.com/curl/curl),在目录curl\winbuild\BUILD.WINDOWS.txt文件 ...
- CentOS 7 (Linux) 下载百度网盘大文件
这个方法不仅适合下载 "百度网盘" 中的文件,还可以下载磁链之类的,总之,就是能够加快下载速度的方法. (参考了网上的多篇文章,自行实践,成功下载度盘大文件,并且提升了下载速度) ...
- 8、SRR数据下载https://ftp-trace.ncbi.nlm.nih.gov/sra/sdk/2.8.2/
1.prefetch SRRxxxxxx -/ncbi/public/sra 2.fastq-dump --split-files xxxxxxsra 3.SRA.SAM以及Fastq ...
随机推荐
- vs2013添加mysql对EF的支持(转+说明)
在vs2013中使用mysql连接entityFramework经常会遇到这个问题:您的项目引用了最新实体框架:但是,找不到数据连接所需的与版本兼容的实体框架数据提供程序.请退出此向导,安装兼容提供程 ...
- loj#6062. 「2017 山东一轮集训 Day2」Pair hall定理+线段树
题意:给出一个长度为 n的数列 a和一个长度为 m 的数列 b,求 a有多少个长度为 m的连续子数列能与 b匹配.两个数列可以匹配,当且仅当存在一种方案,使两个数列中的数可以两两配对,两个数可以配对当 ...
- vue 监听store中的数值
computed: { isFollow () { return this.$store.state.demo.id; //需要监听的数据 } }, watch: { isFo ...
- python-flask-wtforms
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- php获得时间段的月
1.时间:$start_time = $_GET['start_time']; //2015-01$end_time = $_GET['end_time']; //2015-052.对时间进行拆分:$ ...
- sqlserver用timestamp帮助解决数据并发冲突 转【转】
http://blog.csdn.net/u011014032/article/details/42936783 关于并发请求,网上很多朋友都说的很详细了,我就不在这里献丑了.这里只记录下刚刚完工的那 ...
- MIR7预制发票扣除已经预制的数量(每月多次预制,未即时过账)
业务场景见抬头,有没有标准的解决方案就不说了,也没去考虑... 这个增强还是SAP老表提供的,感谢,省了不少时间. INCLUDE:LMR1MF6S 最后的位置 ENHANCEMENT ZMIR7_0 ...
- 基于Vue + webpack + Vue-cli 实现分环境打包项目
需求由来:我公司项目上线发布至服务器分为三个环境分别为测试环境.预发布环境.生产环境:前期做法是项目通过脚步打包时由脚步把域名和后缀名之类的全部替换成要发布的环境所需要的,因为我公司的项目比较大由许许 ...
- Const的使用
const意味为readonly,即只读,const可被施加于任何作用域内的对象,函数参数,函数返回类型,成员函数本体 使用: const修饰变量时本质是 const在谁后面谁就不可修改,const在 ...
- 动态规划入门——数字三角形(Java)
动态规划的概念对于新手来说枯燥难懂,就算看懂了,做题的时候依旧抓耳挠腮的毫无头绪,这些比较难理解的算法,还是需要根据例子来一步步学习和理解,从而熟练掌握,下面,咱们就通过一个简单的小例子来学习动态规划 ...