linux中curl命令如何使用?
Admin 2021-10-14 群英技术资讯 625 次浏览
这篇文章主要给大家分享linux中curl命令的用法,curl命令使用方法有很多,例如curl url可以获得网址的文本信息,curl -i url可以获取该网址的文本信息以及协议头部信息等等,接下来给大家介绍几种常见的curl命令的使用。
linux中curl命令的使用详情:
1、curl url(获取该网址的文本信息)
curl www.zhujy.com
这就是获取的www.zhujy.com信息
<!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html>
2、curl -i url(获取该网址的文本信息以及协议头部信息)
这就是获取的www.zhujy.com文本信息以及协议头部信息。
HTTP/1.1 200 OK Server: nginx/1.14.0 Date: Mon, 11 Mar 2019 02:06:55 GMT Content-Type: text/html Content-Length: 612 Last-Modified: Mon, 29 Oct 2018 09:52:22 GMT Connection: keep-alive ETag: "5bd6d856-264" Accept-Ranges: bytes <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html>
3、curl -x proxy url(使用代理获取网页文本信息)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Test Page for the Nginx HTTP Server on Fedora</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <style type="text/css"> /*<![CDATA[*/ body { background-color: #fff; color: #000; font-size: 0.9em; font-family: sans-serif,helvetica; margin: 0; padding: 0; } :link { color: #c00; } :visited { color: #c00; } a:hover { color: #f50; } h1 { text-align: center; margin: 0; padding: 0.6em 2em 0.4em; background-color: #294172; color: #fff; font-weight: normal; font-size: 1.75em; border-bottom: 2px solid #000; } h1 strong { font-weight: bold; font-size: 1.5em; } h2 { text-align: center; background-color: #3C6EB4; font-size: 1.1em; font-weight: bold; color: #fff; margin: 0; padding: 0.5em; border-bottom: 2px solid #294172; } hr { display: none; } .content { padding: 1em 5em; } .alert { border: 2px solid #000; } img { border: 2px solid #fff; padding: 2px; margin: 2px; } a:hover img { border: 2px solid #294172; } .logos { margin: 1em; text-align: center; } /*]]>*/ </style> </head> <body> <h1>Welcome to <strong>nginx</strong> on Fedora!</h1> <div> <p>This page is used to test the proper operation of the <strong>nginx</strong> HTTP server after it has been installed. If you can read this page, it means that the web server installed at this site is working properly.</p> <div> <h2>Website Administrator</h2> <div> <p>This is the default <tt>index.html</tt> page that is distributed with <strong>nginx</strong> on Fedora. It is located in <tt>/usr/share/nginx/html</tt>.</p> <p>You should now put your content in a location of your choice and edit the <tt>root</tt> configuration directive in the <strong>nginx</strong> configuration file <tt>/etc/nginx/nginx.conf</tt>.</p> </div> </div> <div> <a href="http://nginx.net/"><img src="nginx-logo.png" alt="[ Powered by nginx ]" width="121" height="32" /></a> <a href="http://fedoraproject.org/"><img src="poweredby.png" alt="[ Powered by Fedora ]" width="88" height="31" /></a> </div> </div> </body> </html>
4、curl -X POST --header"Content-Type:application/json" --data ‘{}’ url (使用post模拟json格式请求接口)
curl -X POST --header "Content-Type:application/json" --data '{}' 127.0.0.1:8088/user/getAllUserInfo
{"resultCode":"0","resultMsg":"成功","data":{"userList":[{"id":"a6fc8f27-e598-11e8-ba67-00163e14685b",
"name":"tom","age":"18","address":"北京1","stage":"NBA"},{"id":"24793d7c-e199-11e8-ba67-00163e14685b",
"name":"tom","age":"18","address":"北京3","stage":"NBA"},{"id":"247acf89-e599-11e8-ba67-00163e14685b",
"name":"jerry","age":"18","address":"深圳22","stage":"NBA"},{"id":"247cdafc-e599-11e8-ba67-00163e14685b",
"name":"james","age":"38","address":"广州d4","stage":"NBA"},{"id":"247ed96c-e599-11e8-ba67-00163e14685b",
"name":"curry","age":"58","address":"上海fv","stage":"NBA"},{"id":"24805b4e-e599-11e8-ba67-00163e14685b",
"name":"kaven","age":"78","address":"陇县","stage":"NBA"},{"id":"2481f851-e599-11e8-ba67-00163e14685b",
"name":"durant","age":"68","address":"富平","stage":"NBA"}]}}
POST 指定请求方式
–header 指定请求头部信息
–data 指定json请求体数据内容
5、curl -I url(仅返回请求头部信息)
curl -I www.zhujy.com.cn
HTTP/1.1 200 OK Server: nginx/1.14.0 Date: Mon, 11 Mar 2019 03:34:29 GMT Content-Type: text/html Content-Length: 612 Last-Modified: Mon, 29 Oct 2018 09:52:22 GMT Connection: keep-alive ETag: "5bd6d856-264" Accept-Ranges: bytes
以上就是linux中curl命令的使用介绍啦,本文的示例仅供参考,希望本文对大家有帮助,如果还想要了解更多linux中curl命令的使用,大家可以继续浏览群英网络其他相关的文章。
文本转载自PHP中文网
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
CentOS下使用lvs实现ftp的负载均衡
区别:在dos中,该命令用于通过循环对文件组中的文件执行命令,语法为“FOR 参数 %变量名 IN (文件或命令) DO 命令”;在linux中,该命令用于通过循环来使用命令集,语法为“for 变量名 in 值列表do 命令 done”。
今天小编分享一篇关于Linux系统压缩文件的方法给大家,对这方面比较感兴趣的朋友,不妨来看一看小编所整理的资料,一定不会让你失望的。
linux中默认有三个分区:1、boot分区,该分区是存储内核及在引导过程中使用文件的分区,是启动linux时使用的一些核心文件;2、swap分区,该分区是linux下的虚拟内存分区,作用是在物理内存使用完之后,将磁盘空间虚拟成内存来使用;3、根分区,也即系统分区,系统内所有的东西都存放在根分区中,也被称为root分区。
乌班图(Ubuntu)是一个以桌面应用为主的Linux操作系统,是世界主流的Linux发行版之一;其名称来自非洲南部祖鲁语或豪萨语的“ubuntu”一词,意思是“人性”“我的存在是因为大家的存在",是非洲传统的一种价值观。
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008