IT袋

当前位置:主页 > 经验教程 > 建站编程 >

curl命令怎么用

curl命令怎么用 curl常用命令及参数详解(12)

更新:2023-08-11 17:28:08 来源:IT袋 作者:马勇
导读:curl命令怎么用,curl https://www.secure-site.com curl is also capable of using client certificates to get/post files from sites that require valid certificates. The only drawback is that the certificate needs to be i

curl命令怎么用

curl https://www.secure-site.com
curl is also capable of using client certificates to get/post files from sites that require valid certificates. The only drawback is that the certificate needs to be in PEM-format. PEM is a standard and open format to store certificates with, but it is not used by the most commonly used browsers. If you want curl to use the certificates you use with your (favourite) browser, you may need to download/compile a converter that can convert your browser's formatted certificates to PEM formatted ones.

Example on how to automatically retrieve a document using a certificate with a personal password:

curl -E /path/to/cert.pem:password https://secure.site.com/
If you neglect to specify the password on the command line, you will be prompted for the correct password before any data can be received.

Many older HTTPS servers have problems with specific SSL or TLS versions, which newer versions of OpenSSL etc use, therefore it is sometimes useful to specify what SSL-version curl should use. Use -3, -2 or -1 to specify that exact SSL version to use (for SSLv3, SSLv2 or TLSv1 respectively):

curl -2 https://secure.site.com/
Otherwise, curl will attempt to use a sensible TLS default version.

Resuming File Transfers
To continue a file transfer where it was previously aborted, curl supports resume on HTTP(S) downloads as well as FTP uploads and downloads.

Continue downloading a document:

curl -C - -o file ftp://ftp.server.com/path/file
Continue uploading a document:

curl -C - -T file ftp://ftp.server.com/path/file
Continue downloading a document from a web server

curl -C - -o file http://www.server.com/
Time Conditions
HTTP allows a client to specify a time condition for the document it requests. It is If-Modified-Since or If-Unmodified-Since. curl allows you to specify them with the -z/--time-cond flag.

For example, you can easily make a download that only gets performed if the remote file is newer than a local copy. It would be made like:

curl -z local.html http://remote.server.com/remote.html
Or you can download a file only if the local file is newer than the remote one. Do this by prepending the date string with a -, as in:

curl -z -local.html http://remote.server.com/remote.html
You can specify a "free text" date as condition. Tell curl to only download the file if it was updated since January 12, 2012:

curl -z "Jan 12 2012" http://remote.server.com/remote.html
Curl will then accept a wide range of date formats. You always make the date check the other way around by prepending it with a dash (-).

DICT
For fun try

curl dict://dict.org/m:curl
curl dict://dict.org/d:heisenbug:jargon
curl dict://dict.org/d:daniel:gcide
Aliases for 'm' are 'match' and 'find', and aliases for 'd' are 'define' and 'lookup'. For example,

curl dict://dict.org/find:curl
Commands that break the URL description of the RFC (but not the DICT protocol) are

相关阅读