cURL 和 Wget 的優缺點各是什麼?知乎使用者2011-04-13 19:55:50

curl

Features and is powered by

libcurl

- a cross-platform library with a stable API that can be used by each and everyone。 This difference is major since it creates a completely different attitude on how to do things internally。 It is also slightly harder to make a library than a “mere” command line tool。

Pipes

。 curl is more in the traditional unix-style, it sends more stuff to stdout, and reads more from stdin in a “everything is a pipe” manner。

Return codes

。 curl returns a range of defined and documented return codes for various (error) situations。

Single shot

。 curl is basically made to do single-shot transfers of data。 It transfers just the URLs that the user specifies, and does not contain any recursive downloading logic nor any sort of HTML parser。

More protocols

。 curl supports FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS, FILE, POP3, IMAP, SMTP, RTMP and RTSP at the time of this writing。 Wget supports HTTP, HTTPS and FTP。

More portable

。 Ironically curl builds and runs on lots of more platforms than wget, in spite of their attempts to keep things conservative。 For example: OS/400, TPF and other more “exotic” platforms that aren‘t straight-forward unix clones。

More SSL libraries

and SSL support。 curl can be built with one out of seven(!) different SSL/TLS libraries, and it offers more control and wider support for protocol details。

curl (or rather libcurl) supports

more HTTP authentication

methods, and especially when you try over HTTP proxies。

Bidirectional

。 curl offers upload and sending capabilities。 Wget only offers plain HTTP POST support。

HTTP multipart/form-data

sending, which allows users to do HTTP “upload” and in general emulate browsers and do HTTP automation to a wider extent

Compression

。 curl supports gzip and inflate Content-Encoding and does automatic decompression。

Wget

Wget is

command line only

。 There’s no lib or anything。

Recursive!

Wget‘s major strong side compared to curl is its ability to download recursively, or even just download everything that is referred to from a remote resource, be it a HTML page or a FTP directory listing。

Older

。 Wget has traces back to 1995, while curl can be tracked back no earlier than 1997。

Less developer activity

。 While this can be debated, I consider three metrics here: mailing list activity, source code commit frequency and release frequency。 Anyone following these two projects can see that the curl project has a lot higher pace in all these areas, and it has indeed been so for several years。

HTTP 1.0

。 Wget still does its HTTP operations using HTTP 1。0, and while that is still working remarkably fine and hardly ever is troublesome to the end-users, it is still a fact。 curl has done HTTP 1。1 since March 2001 (while still offering optional 1。0 requests)。

GPL

。 Wget is 100% GPL v3。 curl is MIT licensed。

GNU

。 Wget is part of the GNU project and all copyrights are assigned to FSF。 The curl project is entirely stand-alone and independent with no organization parenting at all - with almost all copyrights owned by Daniel。

Wget requires

no extra options

to simply download a remote URL to a local file, while curl requires -o or -O。 However trivial, this fact is often mentioned to me when people explain why they prefer downloading with wget。

出處:

http://

daniel。haxx。se/docs/cur

l-vs-wget。html

個人感覺在日常使用上來說,wget簡單一些,下載檔案時直接wget然後貼上URL,curl還要打個 -o 。 而且wget有斷點續傳( -c ),雖然不算常用。

cURL 和 Wget 的優缺點各是什麼?Rio2011-04-13 20:20:28

其實吧,老吳列的那幾點裡面,我覺得 recursive (mirror)是 wget 的殺手鐧!抓站利器。

cURL 和 Wget 的優缺點各是什麼?xLight2011-05-09 17:47:57

下載用wget,

需要強大的http client,用curl

cURL 和 Wget 的優缺點各是什麼?知乎使用者2011-05-10 21:49:47

wget是個專職的下載利器,簡單,專一,極致;而curl可以下載,但是長項不在於下載,而在於模擬提交web資料,POST/GET請求,除錯網頁,等等。

在下載上,也各有所長,wget可以遞迴,支援斷點;而curl支援URL中加入變數,因此可以批次下載。

個人用途上,我經常用wget來下載檔案,加 -c選項不怕斷網;使用curl 來跟網站的API 互動,簡便清晰。

cURL 和 Wget 的優缺點各是什麼?一個藝術家2018-04-20 09:44:00

curl ——user-agent

’Mozilla/5。0 (Windows NT 6。1; WOW64) AppleWebKit/537。36 (KHTML, like Gecko) Chrome/65。0。3325。181 Safari/537。36‘

-H

“AuthenticationRequest”

’api_url‘

使用上述命令爬網站圖片