使用curl在命令行中下载文件
http://m.blog.csdn.net/blog/mayadong7349/7019208
使用curl在命令行中下载文件
linux下curl简单应用详解
http://blog.sina.com.cn/s/blog_4da051a60101drqv.html
(对curl命令的使用比较齐全)
http://blog.csdn.net/csfreebird/article/details/9237925
用curl访问HTTPS站点并登录
http://blog.csdn.net/sjin_1314/article/details/17392675
linux C libcurl https 使用
http://www.ichiayi.com/wiki/tech/curl_ssl
cURL 讀取雙向 ssl 認證 Web Server 網頁方式
http://blog.chinaunix.net/uid-192452-id-3954329.html
若服务端要求客户端认证,需要将pfx证书转换成pem格式
openssl pkcs12 -clcerts -nokeys -in cert.pfx -out client.pem #客户端个人证书的公钥
openssl pkcs12 -nocerts -nodes -in cert.pfx -out key.pem #客户端个人证书的私钥
也可以转换为公钥与私钥合二为一的文件
openssl pkcs12 -in cert.pfx -out all.pem -nodes #客户端公钥与私钥,一起存在all.pem中
执行curl命令
1、使用client.pem+key.pem
curl -k --cert client.pem --key key.pem https://www.xxxx.com
2、使用all.pem
curl -k --cert all.pem https://www.xxxx.com
使用-k,是不对服务器的证书进行检查,这样就不必关心服务器证书的导出问题了。
OpenSSL Verify return code: 20 (unable to get local issuer certificate)
http://stackoverflow.com/questions/11548336/openssl-verify-return-code-20-unable-to-get-local-issuer-certificate
yingc@yingc:~/work/public/solution$ openssl s_client -connect 74.125.128.139:443
CONNECTED(00000003)
depth=2 C = US, O = GeoTrust Inc., CN = GeoTrust Global CA
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
0 s:/C=US/ST=California/L=Mountain View/O=Google Inc/CN=*.google.com
i:/C=US/O=Google Inc/CN=Google Internet Authority G2
1 s:/C=US/O=Google Inc/CN=Google Internet Authority G2
i:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
2 s:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
i:/C=US/O=Equifax/OU=Equifax Secure Certificate Authority
SSL-Session:
Protocol : TLSv1.1
Cipher : ECDHE-RSA-RC4-SHA
Session-ID: 867D004577B0B77EA7ACE36EBEA8234C2BE21ABBEDA4A2B17CD9BEB9CA08E5F8
Session-ID-ctx:
Master-Key: 8C9F4C5E01512A14D6F062DE6BDF33F2032A85215C5449055D25D52151458B5380351D0C84D42215455320E4E2EC473D
Key-Arg : None
PSK identity: None
PSK identity hint: None
SRP username: None
TLS session ticket lifetime hint: 100800 (seconds)
TLS session ticket:
0000 - 17 25 ea c9 98 a9 1d bd-35 01 ce 18 a2 87 ec ea .%......5.......
0010 - 29 19 21 fc 79 a3 e4 23-89 97 f2 52 88 1d d1 0c ).!.y..#...R....
0020 - 2f 69 4c 20 78 9c e4 73-e2 8c 71 aa fa 83 67 84 /iL x..s..q...g.
0030 - 56 8e 1d 3b 55 03 3b ad-b5 bb 6b df 85 d1 a6 af V..;U.;...k.....
0040 - 19 a5 38 41 4a f9 8a 19-52 11 bd 68 e3 5b 47 15 ..8AJ...R..h.[G.
0050 - 3a 84 52 af a4 81 db 90-82 db f2 9d 47 df 00 6f :.R.........G..o
0060 - c5 28 c4 ef 85 94 f0 72-fc 47 7f 38 4f 1f 48 3e .(.....r.G.8O.H>
0070 - 37 ba e1 0e 5c c6 62 05-62 8c 35 27 73 74 73 92 7...\.b.b.5'sts.
0080 - 7a c1 a2 10 12 db b7 be-37 04 8a 56 f3 d1 58 75 z.......7..V..Xu
0090 - df a3 ef 31 ...1
Start Time: 1388745557
Timeout : 300 (sec)
Verify return code: 20 (unable to get local issuer certificate)
openssl s_client -CApath /etc/ssl/certs/ -connect 74.125.128.139:443
Expansion: NONE
SSL-Session:
Protocol : TLSv1.1
Cipher : ECDHE-RSA-RC4-SHA
Session-ID: 932BBA8E505C788ABD841F8FA94E685654264E1076A723C3AF8C6967744A1936
Session-ID-ctx:
Master-Key: A2BA6685C97FFD38906103B6AC7CC01BE017AC4D890D41E8167B5063EA9797C6395F3E01437754B7D9FF7726156C9F55
Key-Arg : None
PSK identity: None
PSK identity hint: None
SRP username: None
TLS session ticket lifetime hint: 100800 (seconds)
TLS session ticket:
0000 - 17 25 ea c9 98 a9 1d bd-35 01 ce 18 a2 87 ec ea .%......5.......
0010 - 5d 6c 40 86 a9 e1 04 35-17 0c 06 ab 8d e1 9c aa ]l@....5........
0020 - 24 4c 13 af a0 6b fe e3-aa bf b0 38 64 67 5e 78 $L...k.....8dg^x
0030 - aa f2 08 b2 74 06 ce 16-21 ab 53 e2 5b 22 3b 41 ....t...!.S.[";A
0040 - 82 dc 11 d3 a5 1c 72 d9-17 11 f8 cc 3b 42 a7 91 ......r.....;B..
0050 - 6d d2 0d 11 2a 0d 8b 25-50 5c e5 65 7a e8 44 d2 m...*..%P\.ez.D.
0060 - 22 94 21 5b 8d dc b6 91-ba ee 09 95 f0 6b 75 1b ".![.........ku.
0070 - 90 bf 19 55 32 21 90 c4-70 c1 76 15 15 cb 9a 43 ...U2!..p.v....C
0080 - e8 00 16 77 10 fc 7c a3-d6 8f 73 37 c9 2e b4 0e ...w..|...s7....
0090 - 07 d5 1d 90 ....
Start Time: 1388745845
Timeout : 300 (sec)
Verify return code: 0 (ok)
Curl和Wget访问HTTPS连接出现Unable to establish SSl connection错误
- wget 使用 –no-check-certificate 参数
- curl 使用 -k或者--insecure 参数
./curl -o aa.js https://s.ytimg.com/yts/jsbin/html5player-vf
lG49soT.js --cacert /dvb/ca-certificates.crt
、
curl: (60) SSL certificate problem, verify that the CA cert is:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
More details here: http://curl.haxx.se/docs/sslcerts.html
curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
the bundle, the certificate verification probably failed due to a
problem with the certificate (it might be expired, or the name might
not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
the -k (or --insecure) option.
curl: curl是利用URL语法在命令行方式下工作的文件传输工具。 [百科: http://baike.baidu.com/view/1326315.htm]
官网: http://curl.haxx.se/
其中libcurl有C语言、Python接口(PyCurl: http://pycurl.sourceforge.net/)等等。 curl.exe也可以作为一个命令行下载工具。
将来学习了多线程, 可以改为多线程下载
。
最简单的下载语法:
curl -o [filename] <url>
例如:
Microsoft Windows [版本 6.0.6001]
版权所有 (C) 2006 Microsoft Corporation。保留所有权利。 C:\Windows\system32>curl -o E:\MIT_BIH_Arrhythmia_Database\103.dat http://physionet.org/physiobank/database/mitdb/103.dat
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
1 1904k 1 23082 0 0 3582 0 0:09:04 0:00:06 0:08:58 3556
这样子就从网页http://physionet.org/physiobank/database/mitdb/103.dat把文件103.dat下载到本地E盘E:\MIT_BIH_Arrhythmia_Database\103.dat
curl --head <url>
获取下载文件的大小。例如:
C:\Windows\system32>curl --head http://physionet.org/physiobank/database/mitdb/100.atr
HTTP/1.1 200 OK
Date: Mon, 28 Nov 2011 05:35:46 GMT
Server: Apache/2.2.17 (Fedora)
Last-Modified: Thu, 30 Jul 1992 01:21:18 GMT
ETag: "82c1c18-11ce-287fa5a2e9f80"
Accept-Ranges: bytes
Content-Length: 4558
Connection: close
Content-Type: application/octet-stream
curl --connect-timeout <seconds> <url>
(参考: http://blog.csdn.net/learnhard/article/details/5683703)
连接超时时间设置。
curl -m <seconds> <url>
传输数据超时时间设置。 例如:
C:\Windows\system32>curl -o E:\MIT_BIH_Arrhythmia_Database\104.dat -m 20 "http://physionet.org/physiobank/database/mitdb/104.dat"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
1 1904k 1 20162 0 0 953 0 0:34:06 0:00:21 0:33:45 377
curl: (28) Operation timed out after 20000 milliseconds with 20162 out of 195000
0 bytes received
更多命令请参考:
http://blog.csdn.net/lizhitao/article/details/6039473
# !/usr/bin/env python
# Filename: down.py
# download files from http://physionet.org/physiobank/database/mitdb/ import os home = r"E:\MIT_BIH_Arrhythmia_Database"
fext = [".atr", ".dat", ".hea"]
hurl = r"http://physionet.org/physiobank/database/mitdb/" for ext in fext:
for index in range(100, 234):
fname = str(index) + ext
fsave = home + os.path.sep + fname
fget = hurl + fname
if False == os.path.isfile(fsave):
command = "curl -o " + fsave + " " + fget
os.system(command)
http://blog.csdn.net/sjin_1314/article/details/17392675
使用curl在命令行中下载文件的更多相关文章
- curl命令上传下载文件
下载单个文件,默认将输出打印到标准输出中(STDOUT)中 curl http://www.centos.org 通过-o/-O选项保存下载的文件到指定的文件中: -o:将文件保存为命令行中指定的文件 ...
- 在命令行中如何访问Program Files文件夹(转)
通常来说Program Files文件夹位于C盘,也就是C:\Program File.为了保证兼容性,在命令行中通常使用环境变量%ProgramFiles%来表示Program Files的具体路径 ...
- mysql中如何在命令行中,执行一个SQL脚本文件?
需求描述: 在mysql数据库的使用中,有的时候,需要直接在shell的命令行中,执行某个SQL脚本文件, 比如,要初始化数据库,创建特定的存储过程,创建表等操作,这里进行一个基本的测试. 一般情况, ...
- Shell 命令行 从日志文件中根据将符合内容的日志输出到另一个文件
Shell 命令行 从日志文件中根据将符合内容的日志输出到另一个文件 前面我写了一篇博文Shell 从日志文件中选择时间段内的日志输出到另一个文件,利用循环实现了我想要实现的内容. 但是用这个脚本的同 ...
- 在Linux命令行中以图形化窗口打开文件夹
Linux 系统中也有类似的命令.Ubuntu 发行版的命令行中,我们可以使用 nautilus 命令来打开指定目录的图形化窗口界面.类似下面命令这样使用: nautilus /home/testPr ...
- 在 Linux/windows下 命令行中使用和执行 PHP 代码[交互式php]
[注释]在ubuntu下,升级php到7.1版本,虽然提示的是Interactive mode enabled, 但实际上可以直接书写命令,和interactive shell效果一样. 一:wind ...
- linux下常用FTP命令 上传下载文件【转】
1. 连接ftp服务器 格式:ftp [hostname| ip-address]a)在linux命令行下输入: ftp 192.168.1.1 b)服务器询问你用户名和密码,分别输入用户名和相应密码 ...
- Python通过调用windows命令行处理sam文件
Python通过调用windows命令行处理sam文件 以samtools软件为例 一.下载或者索取得到windows版本的samtools软件,解压后如下: 进入文件内部,有如下几个文件: 二.将s ...
- Java实现命令行中的进度条功能
前言 最近在写一个命令行中的下载工具,既然是下载文件用的,那么实时显示下载进度是非常有必要的.因此,就有了这里对进度条的实现尝试. 预览图 还是先预览下效果图吧. 这里是cmd里面的效果,总体看着还行 ...
随机推荐
- BZOJ 4726 POI 2017 Sabota? 树形DP
4726: [POI2017]Sabota? Time Limit: 20 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 128 Solved ...
- CF 277.5 B.BerSU Ball 二分图的最大匹配 模版题
题意:求二分图的最大匹配数量 模版如下: //二分图匹配(匈牙利算法的DFS实现) //初始化:g[][]两边顶点的划分情况 //建立g[i][j]表示i->j的有向边就可以了,是左边向右边的匹 ...
- Git_分支管理策略
通常,合并分支时,如果可能,Git会用Fast forward模式,但这种模式下,删除分支后,会丢掉分支信息. 如果要强制禁用Fast forward模式,Git就会在merge时生成一个新的comm ...
- Maven项目META-INF文件夹不存在的问题
直接在resources文件夹下新建META-INF文件夹即可. 参考: https://my.oschina.net/KingPan/blog/750159 https://stackoverflo ...
- 特殊字符\u2028导致的Javascript脚本异常
这原本是个小错误,但排查花了不少时间,因此写下来和大家分享一下. 起因 通过Ajax动态从后台读取文章内容,并显示在页面上,加载到某篇文章的时候,报javascript语法错误,无法显示文章内容. A ...
- 正确理解java编译时,运行时以及构建时这三个概念
Java中的许多对象(一般都是具有父子类关系的父类对象)在运行时都会出现两种类型:编译时类型和运行时类型,例如:Person person = new Student();这行代码将会生成一个pers ...
- ndk 开发
5.用NDK来编译程序 1. 现在我们用安装好的NDK来编译一个简单的程序吧,我们选择ndk自带的例子hello-jni,我的位于E:/android-ndk-r5/samples/hello-jn ...
- java静态初始化数据
1.通过静态成员变量和静态方法组合(比较单一) public class A{ private static String t=getInit(); private static String get ...
- FFmpeg深入分析之零-基础
FFmpeg是相当强大的多媒体编解码框架,在深入分析其源代码之前必须要有基本的多媒 体基础知识,否则其源代码会非常晦涩难懂.本文将从介绍一些基本的多媒体只是,主要是为研读ffmpeg源代码做准备,比如 ...
- Jetty学习二:配置概览-怎么配置Jetty
Jetty POJO配置 Jetty的核心组件是Plain Old Java Objects(POJOs):配置Jetty的大部分工作就是在Jetty POJOs上的初始化.装配和设置域的处理,你能通 ...