首页 运维 linux运维 linux中curl命令详解

linux中curl命令详解

Oct 14, 2020 pm 05:06 PM
curl命令

linux中curl命令的使用详情:1、【curl url】获取该网址的文本信息;2、【curl -i url】获取该网址的文本信息以及协议头部信息;3、【curl -x proxy url】使用代理获取网页文本信息。

linux中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 &#39;{}&#39;  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视频教程

以上是linux中curl命令详解的详细内容。更多信息请关注PHP中文网其他相关文章!

本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
4 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
4 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
4 周前 By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解锁Myrise中的所有内容
1 个月前 By 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

如何在Linux中使用正则表达式(REGEX)进行模式匹配? 如何在Linux中使用正则表达式(REGEX)进行模式匹配? Mar 17, 2025 pm 05:25 PM

本文介绍了如何在Linux中使用正则表达式(REGEX)进行模式匹配,文件搜索和文本操作,详细列式,命令和工具,例如GREP,SED和AWK。

如何使用TOP,HTOP和VMSTAT等工具来监视Linux中的系统性能? 如何使用TOP,HTOP和VMSTAT等工具来监视Linux中的系统性能? Mar 17, 2025 pm 05:28 PM

本文讨论了使用TOP,HTOP和VMSTAT监视Linux系统性能,并详细介绍其独特功能和自定义选项,以进行有效的系统管理。

如何在Linux中实现SSH的两因素身份验证(2FA)? 如何在Linux中实现SSH的两因素身份验证(2FA)? Mar 17, 2025 pm 05:31 PM

本文提供了有关使用Google Authenticator在Linux上设置两因素身份验证(2FA)的指南,详细介绍了安装,配置和故障排除步骤。它突出了2FA的安全益处,例如增强的SEC

如何使用软件包管理器(APT,YUM,DNF)管理Linux中的软件包? 如何使用软件包管理器(APT,YUM,DNF)管理Linux中的软件包? Mar 17, 2025 pm 05:26 PM

文章讨论了使用APT,YUM和DNF在Linux中管理软件包,涵盖安装,更新和删除。它比较了它们对不同分布的功能和适用性。

如何使用sudo向Linux的用户授予高架特权? 如何使用sudo向Linux的用户授予高架特权? Mar 17, 2025 pm 05:32 PM

本文解释了如何管理Linux中的Sudo特权,包括授予,撤销和安全性最佳实践。关键重点是安全和sudoers安全和限制访问。Character数量:159

关键Linux操作:初学者指南 关键Linux操作:初学者指南 Apr 09, 2025 pm 04:09 PM

Linux初学者应掌握文件管理、用户管理和网络配置等基本操作。1)文件管理:使用mkdir、touch、ls、rm、mv、cp命令。2)用户管理:使用useradd、passwd、userdel、usermod命令。3)网络配置:使用ifconfig、echo、ufw命令。这些操作是Linux系统管理的基础,熟练掌握它们可以有效管理系统。

Linux的5支支柱:了解他们的角色 Linux的5支支柱:了解他们的角色 Apr 11, 2025 am 12:07 AM

Linux系统的五大支柱是:1.内核,2.系统库,3.Shell,4.文件系统,5.系统工具。内核管理硬件资源并提供基本服务;系统库为应用程序提供预编译函数;Shell是用户与系统交互的接口;文件系统组织和存储数据;系统工具用于系统管理和维护。

Linux维护模式:工具和技术 Linux维护模式:工具和技术 Apr 10, 2025 am 09:42 AM

在Linux系统中,可以通过在启动时按特定键或使用命令如“sudosystemctlrescue”进入维护模式。维护模式允许管理员在不受干扰的情况下进行系统维护和故障排除,如修复文件系统、重置密码、修补安全漏洞等。

See all articles