Curl 是基于 URL 语法在命令行方式下工作的文件传输工具,它支持 FTP,FTPS,HTTP,HTTPS,GOPHER,TELNET,DICT,FILE及LDAP等协议。
Curl 支持 HTTPS 认证,并且支持 HTTP 的 POST,PUT 等方法,FTP上传,kerberos认证,HTTP上传,代理服务器,cookies,用户名/密码认证。
通过 HTTP 代理服务器上传文件到 FTP 服务器等等,功能十分强大。
今日分享一些日常工作中常用的场景
示例:
curl -X GET http://www.xxx.com/search?data=123
示例:
curl -o /dev/null -s -w "time_namelookup:%{time_namelookup}\ntime_connect: %{time_connect}\ntime_starttransfer: %{time_starttransfer}\ntime_total: %{time_total}\n" www.xxx.com
示例:
curl www.xxx.com/api/openservice/query/queryProperty -H "Content-Type:application/json" -X POST -d '{"baseCondition": {"propertyId": 1, "dateRange": {"fromDate": "2019-07-04", "toDate": "2019-07-05"}, "adults": 1,"children": 0, "rooms": 1, "channelId": 2, "sellCategories": ["PUBLIC", "NEGOTIATE"]},"extensionCondition": {"rateIds": [], "unableFlag":"False", "currency": "CNY"}, "context": {}}'
示例:
curl -o /dev/null -s -w "time_namelookup:%{time_namelookup}\ntime_connect: %{time_connect}\ntime_starttransfer: %{time_starttransfer}\ntime_total: %{time_total}\n" www.xxx.com/api/openservice/query/queryProperty -H "Content-Type:application/json" -X POST -d '{"baseCondition": {"propertyId": 1, "dateRange": {"fromDate": "2019-07-04", "toDate": "2019-07-05"}, "adults": 1,"children": 0, "rooms": 1, "channelId": 2, "sellCategories": ["PUBLIC", "NEGOTIATE"]},"extensionCondition": {"rateIds": [], "unableFlag":"False", "currency": "CNY"}, "context": {}}'
示例:
curl -o file.html http://www.xxx.com/index.html
示例:
curl -u name:passwd http://www.xxx.com
示例:
curl -H "Content-Type:application/json" http://www.xxx.com
示例:
curl -b "cookie.txt" http://www.xxx.com
示例:
curl -b "cookie.txt" -F "file=@/temp/a.txt" http://www.xxx.com/api/upload -v
示例:
curl -# -o abc.jpg http://www.xxx.com/abc.JPG
示例:
curl -XDELETE http://10.8.102.102:9200/entity-beta-ars6_ars-reservation -uadmin:admin #清理ES