Linux常用下載工具--curl

常規訪問

curl http://www.myh0st.cn

文件名正則

curl ftp://ftp.myh0st.cn/file[1-100].txt  
curl ftp://ftp.myh0st.cn/file[1-100:10].txt  
curl ftp://ftp.myh0st.cn/file[001-100].txt  
curl ftp://ftp.myh0st.cn/file[a-z].txt  
curl  ftp://ftp.myh0st.cn/file[a-z:2].txt  

域名正則

curl http://site.{one,two,three}.com  

目錄正則

curl http://www.myh0st.cn/archive[1996-1999]/vol[1-4]/part{a,b,c}.html  

常規下載頁面

curl -o index.html http://www.myh0st.cn/  
curl http://www.myh0st.cn/ > index.html  

添加下載進度條

curl -# http://www.myh0st.cn/   > index.html  

使用不同的版本的http協議

默認1.0版本
curl -0 http://www.myh0st.cn  
指定版本
curl --http1.1 http://www.myh0st.cn
curl --http2 http://www.myh0st.cn  

使用不同的ssl版本訪問

tlsv1
curl -1 http://www.myh0st.cn  
curl --tlsv1 http://www.myh0st.cn
sslv2 
curl -2 http://www.myh0st.cn  
curl --sslv2 http://www.myh0st.cn
sslv3 
curl -3 http://www.myh0st.cn  
curl --sslv3 http://www.myh0st.cn

使用不同的ip協議

ipv4
curl -4 http://www.myh0st.cn  
curl --ipv4 http://www.myh0st.cn
ipv6
curl -6 http://www.myh0st.cn  
curl --ipv6 http://www.myh0st.cn

指定user-agent

curl -A "wget/1.0" http://www.myh0st.cn  
curl --user-agent "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"  http://www.myh0st.cn  
curl --user-agent "Mozilla/4.73 [en] (X11; U; Linux 2.2.15 i686)"  http://www.myh0st.cn  

指定cookie

curl -b "phpsession=Testtest" http://www.myh0st.cn  
curl --cookie "name=Daniel" http://www.myh0st.cn  

指定cookie文件

curl -c cookies.txt http://www.myh0st.cn  
curl --cookie-jar cookies.txt http://www.myh0st.cn  

提交post數據

curl -d "username=admin&password=pass" http://www.myh0st.cn  
curl --data "birthyear=1905&press=%20OK%20"  http://www.myh0st.cn/when.cgi
curl --data-urlencode "name=I am Daniel" http://curl.haxx.se
curl --data "<xml>" --header "Content-Type: text/xml" --request PROPFIND url.com

指定referer

curl -e "http://www.myh0st.cn/referer" http://www.myh0st.cn  
curl --referer http://www.myh0st.cn/referer http://www.myh0st.cn  

指定header

curl --header "Host:www.myh0st.cn" http://www.myh0st.cn  
顯示訪問網頁的header
curl -D - http://www.myh0st.cn  
curl --dump-header headers_and_cookies http://www.myh0st.cn

跟隨location跳轉頁面

curl -L http://www.myh0st.cn
curl --location http://www.myh0st.cn

指定dns訪問網站

curl --dns-servers 8.8.8.8 http://www.myh0st.cn

指定證書訪問https的網頁

curl --cert mycert.pem https://www.myh0st.cn
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章