首頁 運維 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.能量晶體解釋及其做什麼(黃色晶體)
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
3 週前 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發行版? Mar 14, 2025 pm 04:45 PM

本文詳細介紹了構建和自定義Linux發行版,涵蓋選擇基本系統的過程,使用LFS和基於Debian的系統,自定義軟件包以及修改內核的構建工具。它還討論了管理軟件

如何在Linux(靜態IP,DHCP,DNS)中配置網絡? 如何在Linux(靜態IP,DHCP,DNS)中配置網絡? Mar 14, 2025 pm 04:55 PM

本文提供了有關配置Linux網絡的指南,重點是設置靜態IP,DHCP和DNS配置。它詳細介紹了編輯配置文件和重新啟動網絡服務以應用更改的步驟。

最受歡迎的Linux發行版是什麼(Ubuntu,Debian,Fedora,Centos)? 最受歡迎的Linux發行版是什麼(Ubuntu,Debian,Fedora,Centos)? Mar 14, 2025 pm 04:50 PM

文章討論了流行的Linux發行版:Ubuntu,Debian,Fedora和Centos,重點介紹了它們對不同用戶的獨特功能和適合性。它比較了Ubuntu和Debian的發布週期,軟件可用性和支持,以及高

See all articles