curl-常用功能

curl 的官网:https://curl.se

curl-常用功能

curl 命令参数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
➜  ~ curl --help
Usage: curl [options...] <url>
-d, --data <data> HTTP POST data
-f, --fail Fail fast with no output on HTTP errors #
-h, --help <category> Get help for commands
-i, --include Include protocol response headers in the output
-o, --output <file> Write to file instead of stdout
-O, --remote-name Write output to a file named as the remote file
-s, --silent Silent mode
-T, --upload-file <file> Transfer local FILE to destination
-u, --user <user:password> Server user and password
-A, --user-agent <name> Send User-Agent <name> to server
-v, --verbose Make the operation more talkative
-V, --version Show version number and quit

This is not the full help, this menu is stripped into categories.
Use "--help category" to get an overview of all categories.
For all options use the manual or "--help all".

示例:

1
2
3
4
 curl -i -X GET http://es-cn-7pp2till2001ycze0.elasticsearch.aliyuncs.com:9200/imb_template/_search \
-H 'Content-Type: application/json; charset=utf-8' \
-H 'Authorization: Basic ZWxhc3RpYzpFcyNJbWdCJkUyMEUyMEAwR0lJ' \
-d '{ "_source": ["category"], "query": {"match_all": {}}, "profile": true}' | json
  • 一行不够,可以输入 \ + enter 换行
  • 这里‘| json’ 是用了 npm 安装的json库去格式化返回的json,方便阅读
    1
    npm install -g json

curl-常用功能
http://example.com/2022/11/09/curl/curl-常用功能/
作者
weijun Wu
发布于
2022年11月9日
许可协议