Download file using libcurl in C/C++
http://stackoverflow.com/questions/1636333/download-file-using-libcurl-in-c-c
#include <stdio.h>
#include <curl/curl.h>
/* For older cURL versions you will also need
#include <curl/types.h>
#include <curl/easy.h>
*/
#include <string> size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) {
size_t written = fwrite(ptr, size, nmemb, stream);
return written;
} int main(void) {
CURL *curl;
FILE *fp;
CURLcode res;
char *url = "http://localhost/aaa.txt";
char outfilename[FILENAME_MAX] = "C:\\bbb.txt";
curl = curl_easy_init();
if (curl) {
fp = fopen(outfilename,"wb");
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
res = curl_easy_perform(curl);
/* always cleanup */
curl_easy_cleanup(curl);
fclose(fp);
}
return ;
}
Download file using libcurl in C/C++的更多相关文章
- Csharp:WebClient and WebRequest use http download file
//Csharp:WebClient and WebRequest use http download file //20140318 塗聚文收錄 string filePath = "20 ...
- [Powershell] FTP Download File
# Config $today = Get-Date -UFormat "%Y%m%d" $LogFilePath = "d:\ftpLog_$today.txt&quo ...
- FTP Download File By Some Order List
@Echo Off REM -- Define File Filter, i.e. files with extension .RBSet FindStrArgs=/E /C:".asp&q ...
- httpClient download file(爬虫)
package com.opensource.httpclient.bfs; import java.io.DataOutputStream; import java.io.File; import ...
- Spring boot download file
Springboot对资源的描述提供了相应的接口,其主要实现类有ClassPathResource.FileSystemResource.UrlResource.ByteArrayResource. ...
- Springboot Download file
@RequestMapping(value = "/downloadSvt") public ResponseEntity<FileSystemResource> ex ...
- jQuery download file
jQuery.download = function (url, method, p, c, e, i, o, goodsType, reciveUser, suplier) { jQuery('&l ...
- download file by python in google colab
https://stackoverflow.com/questions/15352668/download-and-decompress-gzipped-file-in-memory You need ...
- [PHP学习教程 - 网络]001.下载/采集远程文件到本地(Download File)
引言:如何把http://mzitu.com里的图片全部下载下来呢? 一身浩然正气的AC陷入的深思.... 当然这里涉及到的功能有线程,网页请求,页面提取,下载图片等等.今天,我们先讲一下如何下载文件 ...
随机推荐
- php字符串首字母转换大小写的实例
in: 后端程序首字母变大写:ucwords() <?php$foo = 'hello world!';$foo = ucwords($foo); // Hello World!$bar = ' ...
- ionic入门之AngularJS扩展基本布局
目录: 标题栏 : ion-header-bar 页脚栏 : ion-footer-bar header/footer : 样式及内容 内容区 : ion-content 滚动框 : ion-scro ...
- DOM4J解析xml案例
- linux信号机制 - 用户堆栈和内核堆栈的变化【转】
转自:http://itindex.net/detail/16418-linux-%E4%BF%A1%E5%8F%B7-%E5%A0%86%E6%A0%88 此文只简单分析发送信号给用户程序后,用户堆 ...
- Java中常见数据结构:list与map
1:集合 Collection(单列集合) List(有序,可重复) ArrayList 底层数据结构是数组,查询快,增删慢 线程不安全,效率高 Vector 底层数据结构是数组,查询快,增删慢 线程 ...
- jQuery的Ajax的跨域请求
今天碰到一个Ajax跨域请求的问题,我把源码down下来,然后在服务器端写了一个http请求的代理(因为服务器端是不存在跨域问题的),说白了就是用BufferedReader写了个IO流,然后读取到目 ...
- CSS选择器无法找到td
.table > tr > td <----这样无法找到td 因为table在浏览器下会自动生成tbody,这样即可 .table > tbody > tr > ...
- maven:log4j:WARN No appenders could be found for logger (loggerInfo).或者maven build error:org.apache.maven.lifecycle.LifecycleExecutionExceptio
maven在build构建时,加载资源文件时需要配置资源文件插件: 1,在pom.xml文件中加入 <build> <finalName>${project.build.tar ...
- 使用Jil序列化JSON提升Asp.net web api 性能
JSON序列化无疑是Asp.net web api 里面性能提升最重要的一环. 在Asp.net web api 里面我们可以插入自定义的MediaTypeFormatter(媒体格式化器), 说白了 ...
- java final .static修饰符
static静态修饰符(使用static修饰符修饰的成员变量.常量.和成员方法成为静态变量.常量和方法,他们统称为静态成员,归整个类所有,不依赖于类的特定实例,被类的所有实例共享,只要这个类被加载,J ...