Transferred from: http://www.cnblogs.com/sunada2005/p/3829772.html
The Curl command can be used to construct an HTTP request. There are many parameters, the usual parameters are as follows:
General Syntax:
Curl [option] [URL ...]
It supports the name extension functionality of the shell when processing URLs, such as http://www.jbxue.com/archive[1996-1999]/vol[1-4]/part{a,b,c}.html can generate multiple desired URLs
Curl's options feature:
- When no parameters are taken, curl returns the data in the specified URL and prints it on the screen
- -U login with username and password. such as curl-uname:passwd URL
- -b/--cookie <name=data> submits a cookie to the server, if none = The name is considered a file name, for example: Curl-b cookie.txt www.jbxue.com
- -O out will specify that curl is returned as an out file, with content from html/jpg to various MIME-type files. such as Curl-o page.html URL
- -D <key=value> Post form data to the server for example: curl-d "order=111&count=2" http://www.jbxue.com/buy
- -a/--user-agent <ua> Specifies the user agent that sends the request, for example: Curl-a my-agent/1.0.0 www.jbxue.com
- -x ip:port Specifies the HTTP proxy used, for example: Curl-x 192.168.1.1:8080 www.jbxue.com
- -D Head.txt saves the returned header of the server as a file, and the head cookie can be saved, For example: curl-d header.txt www.jbxue.com
- If you want to get form data from a local file, add @ before the file name, for example: curl-d @data. xml http://www.jbxue.com
- If you want to get from standard input , use curl-d "Name=username&passwd=pwd" http://www.jbxue.com
- -L When the page has a jump, the output jumps to the page
- -I header information when there is a jump, you can use curl-l-I url|grep location to determine the new URL to jump to the address
- -C <file> Save Server cookie file
- -e URL Sets the value of the reference header
- -T LocalFile put files to the server for example: Curl-t 1.mp3 www.jbxue.com/upload.php
- -F <key=value> post the form to the server, for example: curl-f "[Email protected];type=text/html" Url.com
- -e Cert.pem specifying local certificates
- -H such as curl-h "Connection:keep-alive" http://www.jbxue.com
- -x/--request method User-defined HTTP request methods name such as Curl-x GET www.baidu.com
- --compressed receive the returned data in a compressed manner
- --connect-timeout <s> Set timeout time
- -v Verbose output with header for request and response
- --retry num
- --retry Timeo Specify the number and interval of retries
- --tcp-nodelay Open tcp_nodelay option does not carry a piggyback confirmation
- -O save downloaded files by name on the server
- -r/--range from-to Download the data in the specified range
- -C to continue when saving the file
Environment variable: http_proxy [protocol://]
Curl command Use (GO)