Curl is a file transfer tool that works under the command line using URL rules. It supports file uploads and downloads, so it is a comprehensive transfer tool, but traditionally, the URL is used as a download tool. -a/--append when uploading a file, attach to target file -a/--user-agent <string> set user agent to send to server -anyauth can use "any The authentication method -b/--cookie <name=string/file> cookie string or file read Location -basic uses HTTP Basic authentication -b/--use-ascii Use the ASCII/text transfer -c/--cookie-jar <file> to write the cookie to this file after the operation is complete -c/--continue-at <offset> Breakpoint Continuation -d/--data <data> HTTP post mode transfer data --data-ascii <data> post data in ASCII mode --data-binary <data> post data in binary mode --negotiate use HTTP authentication --digest Use digital authentication --disable-eprt prohibit use of eprt or LPRT&NBSP;--DISABLE-EPSV Disable the use of Epsv -d/--dump-header <file> write header information to the file --egd-file <file> random data (SSL) settings EGD Socket path --tcp-nodelay use tcp_nodelay option -e/--referer Source URL -e/--cert <cert[:p asswd] > Client certificate file and password (SSL) --cert-Type <type> certificate file type (Der/pem/eng) (SSL) --key <key> private key file name (SSL) -- Key-type <type> private key file type (Der/pem/eng) (SSL) --pass <pass> private key password (SSL) --engine <eng > Encryption engine use (SSL). "--engine list" for List --cacert <file> CA certificate (SSL) --capath <directory> CA directory (made using C_rehash) To verify peer against (SSL) --ciphers <list> SSL password --compressed requirements Return is a compressed situation ( Using deflate or gzip) --connect-timeout <seconds> set maximum request time --create-dirs establish a directory hierarchy of local directories --crlf upload is to convert LF into crlf -f/--fail do not display HTTP error when connection fails --ftp-create-dirs if the remote directory does not exist, create a remote directory -- Ftp-method [MULTICWD/NOCWD/SINGLECWD] controlling the use of CWD --ftp-pasv using PASV/EPSV instead of ports --ftp-skip-pasv-ip when using PASV, ignore the IP address --ftp-ssl attempts to use SSL/TLS for FTP data transfer --ftp-ssl-reqd requires SSL/TLS for FTP data transfer -f/--form < Name=content> analog HTTP form submission Data -form-string <name=string> analog HTTP form submission data -g/--globoff disable URL sequence and range using {} and [ ] -g/--get send data as Get -h/--help help -h/--header <line> Custom header information to the server -- ignore-content-length the length of the HTTP header information that is ignored -i/--include output includes protocol header information -I/--head only display document information Read from file-j/--junk-session-cookies ignore session cookie -interface <interface> Specify network interface/address use -KRB4 < level > Enable with the specified security level krb4 -j/--junk-session-cookies read file into ignore session Cookie --interface <interface> use specified network interface/address &NBSP;--KRB4 <level> using the specified security level krb4 -k/--insecure allow the use of certificates to SSL sites -K/--config specified configuration file reads -l/--list-only list the file names under the FTP directory --limit-rate <rate> set transfer speed --local-port<NUM> Force local port number -m/--max-time <seconds> Set Maximum transfer time --max-redirs <num> set the maximum number of read directories --max-filesize <bytes > Set Max DownTotal files downloaded -M/--manual show full manual -n/--netrc read the user name and password from the Netrc file --netrc-optional use. netrc or URL to overwrite-n --ntlm Disable buffered output using HTTP NTLM authentication -n/--no-buffer -o/--output writes the output to the file -o/--remote-name writes the output to the file, retains the file name of the remote Files -p/--proxytunnel uses the HTTP proxy --proxy-anyauth Select either Proxy authentication method --proxy-basic use Basic authentication on the proxy --proxy-digest Use the digital authentication on the proxy --proxy-ntlm use NTLM authentication on the proxy -p/--ftp-port <address> use the port address, Instead of using Pasv -q/--quote <cmd> file transfer, send command to server -r/--range <range> retrieve byte range from http/1.1 or FTP server -- Range-file Read (SSL) random files -R/--remote-time Keep remote file time when generating files locally --retry <num> When there is a problem with the transmission, the number of retries --retry-delay <seconds> The retry interval is set when there is a problem with the transmission --retry-max-time <seconds> When there is a problem with the transmission, set the maximum retry time -s/--silent mute mode. Do not output anything -S/--show-error display error &NBSP;--SOCKS4 Last Updated 2013-05-04 17:44:08
The co-editors are as follows: Zhang Ying Wrong, I'll fix it.
(0) correct
(8) Collection
(0) 2Example 1A, crawl the page content into a file
[Email protected] mytest]# Curl-o home.html
b, with-O (uppercase), the following URL to specific to a file, or not catch it down. We can also use the regular to grab things.
[Email protected] mytest]# Curl-o http://blog.51yip.com/wp-content/uploads/2010/09/compare_varnish.jpg
C, simulate form information, simulate login, save cookie Information
[Email protected] mytest]# curl-c/cookie_c.txt-f log=aaaa-f pwd=****** http://blog.51yip.com/wp-login.php
D, simulate form information, simulate login, save header information
E, using a cookie file
[Email protected] mytest]# curl-b/cookie_c.txt http://blog.51yip.com/wp-admin
F, the breakpoint continues to pass,-C (uppercase)
-----------------------G, transfer the data, it is best to use the login page test, because you pass the value of the past, curl back to grasp the data, you can see that you pass the value has no success
[Email protected] mytest]# curl-d log=aaaa http://blog.51yip.com/wp-login.php
H, which shows the fetch error, is clearly shown in the following example.
[Email protected] mytest]# curl-f http://blog.51yip.com/asdf Curl: The requested URL returned error:404 [[ Email protected] mytest]# Curl HTTP://BLOG.51YIP.COM/ASDF
I, forge source address, some website will judge, request source address.
J, when we often use curl to engage in people's things, people will put your IP to shield off, this time, we can use the agent
[Email protected] mytest]# curl-x 24.10.28.84:32779-o home.html http://blog.51yip.com
K, something bigger than that we can download in sections
[[email protected] mytest]# curl-r 0-100-o img.part1 http://blog.51yip.com/wp-content/uploads/2010/09/compare_ Varnish.jpg% total% Received% xferd Average-time Time time current Dload Upload Total spent Left SPEED100 101 101 0 0 0--:--:----:--:----:--:--0[[email protected] mytest]# Curl-r 100-200-o img.part2 http://blog.51yip.com/wp-content/uploads/2010/09/compare_varnish.jpg% total% Received Xferd Average Speed Time time Dload Upload Total spent left SPEED100 101 100 101 0 0 0 0:00:01 0:00:01--:--:--0[[email protected] mytest]# curl-r 200--o img.part3 http://b Log.51yip.com/wp-content/uploads/2010/09/compare_varnish.jpg% total% Received% xferd Average speed time time Time current Dload Upload Total spent left Speed100 104k 104k 0 0 52793 0 0:00:02 0:00: --:--:--88961[[email p rotected] mytest]# ls |grep part | Xargs du-sh4.0k one.part1112k three.part34.0k two.part2
L, download progress information is not displayed
[Email protected] mytest]# curl-s-o aaa.jpg http://blog.51yip.com/wp-content/uploads/2010/09/compare_varnish.jpg
M, Show download progress bar
[Email protected] mytest]# Curl-#-o http://blog.51yip.com/wp-content/uploads/2010/09/compare_varnish.jpg ######################################################################## 100%
N, download files via FTP
[[email protected] ~]$ curl-u Username: password-o http://blog.51yip.com/demo/curtain/bbstudy_files/style.css % total % Received% xferd Average speed time Time time current dload Upload Total Spent left speed 101 1934 101 1934 0 0 3184 0--:--:----:--:- - --:--:--
O, upload via FTP
[[email protected] ~]$ curl-t test.sql ftp://user name: Password @ip:port/demo/curtain/bbstudy_files/
Below is a detailed explanation of the-w parameter, translated by Me (digdeeply). Please point out the wrong place. (Original in English: http://curl.haxx.se/docs/manpage.html)
The following are the available variable names:
-W,--write-out The following variables will be in the format of curl as appropriate output, output variables need to follow%{variable_name} format, if you need to output%,double, that is, percent, and N is a newline, R is a carriage return, T is the tab.url_effectiveThe URL is fetched last. This is the most meaningful if you've told Curl to follow Location:headers.filename_effectiveThe ultimate filename, the curl writes out to. This was only meaningful if Curl was told to write to a file with the--remote-name or--output option. It ' s most useful in combination with the--remote-header-name option. (Added in 7.25.1)Http_codeHTTP status code, such as 200 success, 301 turn, 404 Not Found, 500 server error, etc. (The numerical response code that is found in the last retrieved HTTP (s) or FTP (s) transfer. In 7.18.2 the alias Response_code is added to show the same info.)Http_connectThe numerical code that is found in the last response (from a proxy) to a Curl CONNECT request. (Added in 7.12.4)Time_TotalTotal time, in seconds. Accurate to three digits after the decimal point. (The total time, in seconds, then the full operation lasted. The time would be displayed with millisecond resolution.)Time_namelookupDNS resolution time, from the start of the request to the time that DNS resolution is complete. (The time, in seconds, it took from the start until the name of resolving was completed.)Time_connectConnection time, from start to establish TCP connection to complete the time spent, including the front DNS resolution time, if you need to simply get the connection time, with this time_connect time minus the front time_namelookup time. The following is the same, no longer repeat. (The time, in seconds, it took from the start until the TCP connect to the remote host (or proxy) is completed.)Time_appconnectConnection establishment completion time, such as ssl/ssh to establish a connection or complete three handshake time. (The time, in seconds, it took from the start until the ssl/ssh/etc Connect/handshake to the remote host was completed. (Added in 7.19.0))Time_pretransferThe time from the start to the ready transfer. (The time, in seconds, it took from the start until the file transfer is just about to begin. This includes all Pre-transfer commands and negotiations that is specific to the particular protocol (s) involved.)Time_redirectREDIRECT time, including several redirected DNS resolutions, connections, pre-transmissions, and transfer times before the last transmission. (The time, in seconds, it took for all redirection steps include name lookup, connect, Pretransfer and transfer before the Final transaction was started. Time_redirect shows the complete execution time for multiple redirections. (Added in 7.12.3))Time_starttransferStart transfer time. The time it took for the WEB server to return the first byte of data after the request was made (the times, in seconds, the it took from the start until the initial byte was just on to be Tran Sferred. This includes Time_pretransfer and also the time of the server needed to calculate the result.)Size_downloadDownload size. (The total amount of bytes that were downloaded.)Size_uploadUpload size. (The total amount of bytes that were uploaded.)Size_headerThe size of the downloaded header (the total amount of bytes of the downloaded headers.)size_requestThe size of the request. (The total amount of bytes, were sent in the HTTP request.)Speed_downloadDownload speed, in units-bytes per second. (The average download speed, the curl measured for the complete download. Bytes per second.)Speed_uploadUpload speed, Units-bytes per second. (The average upload speed, the curl measured for the complete upload. Bytes per second.)Content_TypeIs Content-type, needless to say, this is a visit to my blog The results of the first page return example (text/html; charset=utf-8); (The content-type of the requested document, if There is any.)num_connectsNumber of new connects made in the recent transfer. (Added in 7.12.3)num_redirectsNumber of redirects that were followed in the request. (Added in 7.12.3)Redirect_urlWhen a HTTP request is made without-l to follow redirects, this variable would show the actual URL a redirect would take To. (Added in 7.18.2)Ftp_entry_pathThe initial path Libcurl ended up and when logging on to the remote FTP server. (Added in 7.15.4)Ssl_verify_resultSSL authentication results, return 0 indicates successful authentication. (The result of the SSL Peer certificate verification is requested. 0 means the verification was successful. (Added in 7.19.0)) If you use the-w parameter more than once, the output is in the last format. If This option was used several times, the last one would be used.
Linux Curl Command detailed