Linux curl 命令
生活随笔
收集整理的這篇文章主要介紹了
Linux curl 命令
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
curl is a tool to transfer data from or to a server,?using one of the supported protocols ( http ,https ,ftp ,telnet ,...... )
[root@localhost ~]$ curl http://www.baidu.com/ # 獲取指定頁面,默認將輸出打印到標準輸出(STDOUT)中 [root@localhost ~]$ curl http://www.baidu.com/ -o baidu.html # 獲取指定頁面,并把標準輸出保存到指定文件中 [root@localhost ~]$ curl -I http://www.baidu.com/ # 只顯示指定頁面的頭部信息命令參數:
-I # 只顯示指定頁面的頭部信息,用法如:curl -I http://www.baidu.com/ -o # 把輸出保存到指定的文件中,用法如:curl -o index.html http://www.baidu.com/ -O # 把輸出保存到文件中,這個文件名取自URL中的文件名,如:curl -O http://www.baidu.com/abc.html 會保存一個abc.html文件# 該參數的另一種用法是可以循環下載文件,比如:curl -O http://www.baidu.com/[1-5].jpg 可以把 1.jpg 2.jpg ... 下載下來 -d # 用法發送POST請求,與-X連用,用法如:curl -d "user=tom&pass=123" -X POST http://www.baidu.com/ -X # 指定發送數據的方式,與-d連用,用法如:curl -d "user=tom&pass=123" -X POST http://www.baidu.com/ -C # 斷點續傳,防止下載到一半失敗,用法如:curl -C - -O http://www.baidu.com/index.html,其中的"-"是讓curl自動找到在哪里恢復續傳 -L # 下載重定向后的網頁,用法如:curl -L http://www.baidu.com/ 參考:https://www.jb51.net/article/118402.htm -A # 自定義用戶代理(User-Agent)來獲取頁面,用法如:curl -A "Mozilla/5.0 ... Firefox/35.0" http://www.baidu.com/ -x # 自定義代理服務器來獲取頁面,用法如:curl -x 192.168.100.100:1080 http://www.baidu.com/ -c # 用于保存cookie信息到指定的文件,用法如:curl -c cookie.txt http://www.baidu.com -D # 用于保存header信息到指定的文件,用法如:curl -D header.txt http://www.baidu.com/ -b # 使用指定的cookie文件來獲取頁面,用法如:curl -b cookie.txt http://www.baidu.com/ -e # 偽造盜鏈(referer)來獲取頁面,用法如:curl -e "www.linux.com" http://www.baidu.com/ -u # 使用用戶名和密碼來下載需要授權的頁面,用法如:curl -u username:password http://www.baidu.com/-# # 下載頁面的同時顯示進度條,與--progress用法一致,用法如:curl -# -O http://www.baidu.com/index.html -s/--silent # 下載頁面時不顯示進度條,用法如:curl --silent -O http://www.baidu.com/index.html --progress # 下載頁面時顯示進度條,用法如:curl --progress -O http://www.baidu.com/index.html --limit-rate # 限制下載速度,用法如:curl --limit-rate 10M http://www.baidu.com/
?
?
?
?
?
? ? ?
轉載于:https://www.cnblogs.com/pzk7788/p/10188769.html
總結
以上是生活随笔為你收集整理的Linux curl 命令的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Mysql 存储过程和函数区别
- 下一篇: Windows 环境下 Chrome浏览