当前位置:网站首页>curl 命令妙用
curl 命令妙用
2022-07-04 15:43:00 【Wu_Candy】
curl 介绍:
curl是基于URL语法在命令行方式下工作的文件传输工具,它支持FTP,FTPS,HTTP,HTTPS,GOPHER,TELNET,DICT,FILE及LDAP等协议。curl支持HTTPS认证,并且支持HTTP的POST,PUT等方法,FTP上传,kerberos认证,HTTP上传,代理服务器,cookies,用户名/密码认证,通过http代理服务器上传文件到FTP服务器等等,功能十分强大。本文主要分享一些常用的场景:
curl 常用参数:
-I 只显示请求头信息
-d HTTP POST方式传送数据,以json格式
-o 把输出写到该文件中
-s 静默模式。不输出任何东西
-X 指定什么命令,如GET POST
-v 查看详情
-u 设置服务器的用户和密码
-H 要发送到服务端的自定义请求头
-w 完成后输出什么
-b 从文件中读取cookie信息
-F 上传文件
-# 显示进度条
No 1:curl 命令发送get请求
示例:curl -X GET http://www.xxx.com/search?data=123
No 2:curl 命令发送get请求后统计各阶段耗时
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
No 3:curl 命令发送post请求
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": {}}'
No 4:curl 命令发送post请求后统计各阶段耗时
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": {}}'
No 5:curl 命令保存文件到本地
curl -o file.html http://www.xxx.com/index.html
No 6:curl 命令登录服务
curl -u name:passwd http://www.xxx.com
No 7:curl 命令构造一个请求头
curl -H "Content-Type:application/json" http://www.xxx.com
No 8:curl 命令从文件中读取cookie 信息
curl -b "cookie.txt" http://www.xxx.com
No 9:curl 命令上传文件
curl -b "cookie.txt" -F "[email protected]/temp/a.txt" http://www.xxx.com/api/upload -v
No 10:curl 命令下载文件并显示下载进度
curl -# -o abc.jpg http://www.xxx.com/abc.JPG
No 11:curl 命令清除es 里面的数据
curl -XDELETE http://10.8.102.102:9200/entity-beta-ars6_ars-reservation -uadmin:admin #清理ES
边栏推荐
猜你喜欢
Go micro tutorial - Chapter 2 go micro V3 using gin and etcd
[unity ugui] scrollrect dynamically scales the grid size and automatically locates the middle grid
C# 服务器日志模块
NFT liquidity market security issues occur frequently - Analysis of the black incident of NFT trading platform quixotic
Using win10 scheduling task program to automatically run jar package at fixed time
Congratulations to Mr. Zhang Pengfei, chief data scientist of artefact, for winning the campaign Asia tech MVP 2022
建筑建材行业经销商协同系统解决方案:赋能企业构建核心竞争力
祝贺Artefact首席数据科学家张鹏飞先生荣获 Campaign Asia Tech MVP 2022
VB cannot access database stocks
Hidden corners of coder Edition: five things that developers hate most
随机推荐
Pytorch deep learning quick start tutorial
Ble HCI flow control mechanism
Is it safe for Bank of China Securities to open an account online?
NFT流动性市场安全问题频发—NFT交易平台Quixotic被黑事件分析
The test experience "tortured" by the PMP test is worth your review
整理混乱的头文件,我用include what you use
Linear time sequencing
完美融入 Win11 风格,微软全新 OneDrive 客户端抢先看
tp配置多数据库
KS007基于JSP实现人个人博客系统
How to "use" Perl modules in directories that are not in @inc- How do I 'use' a Perl module in a directory not in @INC?
安信证券属于什么档次 开户安全吗
Go development: how to use go singleton mode to ensure the security of high concurrency of streaming media?
长城证券安全不 证券开户
C# 服务器日志模块
R language plot visualization: plot visualizes overlapping histograms and uses geom at the top edge of the histogram_ The rug function adds marginal rug plots
【云原生】服务网格是什么“格”?
Two methods of MD5 encryption
Visual studio 2019 (localdb) mssqllocaldb SQL Server 2014 database version is 852 and cannot be opened. This server supports 782
Yanwen logistics plans to be listed on Shenzhen Stock Exchange: it is mainly engaged in international express business, and its gross profit margin is far lower than the industry level