curl finishing

curl

(1) curl url: View page source
curl -o [- output] filename url : the preserved pages, the equivalent of wget
culr -O url: url must be specific to a file
curl -L URL: automatically jump
curl - i url: displaying header information, -I displays only the header information
curl -v url: display communication process
curl --trace outputfile url: more detailed communication procedure
curl --trace-ascii outputfile url: more detailed communication procedure
outputfile If - the output to stdout

(2) GET and the POST: -d, - Data
the POST: default file application / X-WWW-form-urlencoded
curl -d "User password = & = XXX XXX" http://www.yahoo.com/login.cgi
this It is a parameter directly in the inside of the header

May be: the -X-curl the POST -d "User password = & = XXX XXX" http://www.yahoo.com/login.cgi
If the data has not been encoded form, the encoding can be used to provide curl: curl -X POST --data -urlencode "date = April 1" example.com/form.cgi

POST: application / json: curl -X POST -H 'Content-Type: application / json' example.com/form.cgi -d '{ "hello": "world"}'
This method is json data directly in the body inside

Analog form submission data: -F, --form
transmission form information using the GET method: curl example.com/form.cgi?para=xxx

(3) curl default HTTP method is GET, use -X, --request choose other methods
-X POST
-X DELETE

(4) Send cookie: or -b --cookie
curl --cookie "XXX name =" URL
As a specific cookie value can be obtained from http response header information of 'Set-Cookie' field
Note: After may -b with files, --cookie not be
-c cookie-file: save the cookie returned by the server to the cookie-file file
-b cookie-file: as a cookie request information using the cookie-file file

(5) adding header information: -H or --header
curl --header "the Type-the Content: file application / JSON" http://example.com

(6)HTTP认证: -u or --user
curl --user name:password http://example.com

(7) -I, --head: Displays HTTP-header, is often used to test the connection itself

(8) -e: forged source address, some sites will judge, requesting the source address
curl -e HTTP: // localhost http://www.sina.com.cn

(9) - #: display download progress bar
curl - # -O http://www.mydomain.com/linux/25002_3.html

(10) return value test page (in the script, it is very common to test whether the normal usage of the site)
curl -o / dev / null -s -w%} {HTTP_CODE www.sina.com.cn

Guess you like

Origin www.cnblogs.com/vdvvdd/p/11205941.html