它們的區別,我看到的有以下幾點:
1.curl是libcurl這個庫支持的,wget是一個純粹的命令行命令。
2.curl支持更多的協議。curl supports FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS, FILE, POP3, IMAP, SMTP and RTSP at the time of this writing.php
Wget supports HTTP, HTTPS and FTP.
3.curl 默認支持HTTP1.1(也支持1.0),html
而wget僅僅支持HTTP1.0規範。引用wget的man page中的一段話吧,Please be aware that Wget needs to know the size of the POST data in advance. It's not quite clear how to work around this limitation inherent in HTTP/1.0. Although HTTP/1.1 introduces chunked transfer that doesn't require knowing the request length in advance, a client can't use chunked unless it knows it's talking to an HTTP/1.1 server. And it can't know that until it receives a response, which in turn requires the request to have been completed -- a chicken-and-egg problem.
4.curl在指定要下載的連接時可以支持URL的序列或集合,而wget則不能這樣;
5.wget支持遞歸下載,而curl則沒有這個功能。(這是wget的一個主要好處,wget也是有優點的,呵呵)
web
對比可參照:http://daniel.haxx.se/docs/curl-vs-wget.html瀏覽器
多線程下載可使用axel和mwget緩存
一、wget 遞歸下載及替換URL
服務器
wget -r -p -np -k http://docs.saltstack.cn/zh_CN/latest/topics/tutorials/index.html
cookie
二、使用 Curl 測試cookie來記錄session信息session
像IE/FF這樣的瀏覽器,固然能夠輕易處理cookie信息,但curl呢?
option: -D 參數是用來存cookie
$curl -D cookie0001.txt http://www.php-oa.com
這樣,當頁面被存到page.html的同時,cookie信息也被存到了cookie0001.txt裏面了
那麼,下一次訪問的時候,如何繼續使用上次留下的cookie信息呢?要知道,高級防盜鏈在不少網站都是靠監視你的cookie信息,來判斷你是否是不按規矩訪問他們的網站的.
此次咱們使用這個option來把上次的cookie信息追加到http request裏面去: -b
$curl -D cookie0002.txt -b cookie0001.txt http://www.php-oa.com
這樣,咱們就能夠幾乎模擬全部的IE操做,去訪問網頁了!、多線程
三、Curl 來控制是瀏覽器信息
在CDN的緩存服務器中,咱們要看給的瀏覽器是什麼類型,能夠用curl給咱們提供了一個有用的option,可讓咱們隨意指定本身此次訪問所宣稱的本身的瀏覽器信息: -A
$curl -A "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" http://www.php-oa.com
這樣,服務器端接到訪問的要求,會認爲你是一個運行在Windows 2000上的IE6.0
四、 Curl 來控制 Referer
另一個緩存服務器端經常使用的限制方法,就是檢查http訪問的referer.好比你先訪問首頁,再訪問裏面所指定的下載頁,這第二次訪問的referer地址就是第一次訪問成功後的頁面地址.這樣,服務器端只要發現對下載頁面某次訪問的referer地址不 是首頁的地址,就能夠判定那是個盜連了~~~~~
curl給咱們提供了設定referer的option: -e
$curl -e "http://mail.php-oa.com" http://www.php-oa.com
這樣,就能夠騙對方的服務器,你是從mail.php-oa.com點擊某個連接過來的了,呵呵呵less
五、 Curl 多線程下載和斷點續傳的測試
在緩存服務器中能夠控制req_header Range的參數,咱們怎麼用curl來控制啦.
好比咱們下載aaa.jpg中,忽然掉線了,咱們就能夠這樣開始續傳
$curl -c -O http://www.php-oa.com/aaa.jpg
六、多線程分片下載,:
$curl -r 0-10240 -o "zhao.part1" http:/cgi2.tky.3web.ne.jp/~zzh/zhao1.mp3