linux - wget和curl各有何用处?(强大但是不知如何使用)
黄舟
黄舟 2017-04-17 15:41:47
0
3
522

描述问题

在我使用它们的有限时间里, 一直wget==文件下载器==curl, 但是见许多REST文档中都拿curl做例子,便man curl, 发现其简介如下:

curl  is  a tool to transfer data from or to a server, using one of the supported
       protocols (HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, DICT, TELNET, LDAP or  FILE).
       The command is designed to work without user interaction.

       curl  offers  a busload of useful tricks like proxy support, user authentication,
       FTP upload, HTTP post, SSL connections, cookies, file transfer resume  and  more.
       As you will see below, the number of features will make your head spin!

       curl  is powered by libcurl for all transfer-related features. See libcurl(3) for
       details.

英文浅显易懂, 我想: 功能这么强大, 估计又难免记忆一大堆参数(痛苦)

大家是如何用的?

上下文环境

  1. Linux纯命令行-Server

重现

相关代码

  1. man curl

  2. man wget

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(3)
刘奇

wget

One sentence: Built-in file download tool

Advantages:

  • Built-in in most distributions

  • Supports simple recursive website removal

  • Suitable for downloading, writing files by default

Disadvantages:

  • Generally only used for downloading, assembling post requests, sending complex headers, etc. are not commonly used

  • The download function is relatively primitive and does not support concurrency, p2p, magnet links, etc.

curl

In one sentence: Built-in request sending tool + request sending library

Advantages:

  • Built-in in most distributions

  • To some extent, it is the default for expressing an http request (for example, chrome development tools can be directly copied to curl, for example, many API interface documents directly provide curl commands)

  • Stdout is output by default, making it easy to pipe other commands (common one-sentence installation curl xxx | bash)

  • At the same time, libcurl is a stable and commonly used class library, which is easy to integrate into other projects

Disadvantages:

  • Additional parameters are required for downloading

  • It is relatively troublesome to splice complex requests

httpie

In one sentence: modern http request sending tool

Advantages:

  • It is very convenient to splice json requests and is suitable for adjusting "modern" restful interfaces

  • Supports using files to record sessions (cookies, fixed request headers, etc.), suitable for adjusting interfaces

  • The parameters are clear and simple, and you can get started quickly

  • The returned results are highlighted

Disadvantages:

  • You have to pretend it yourself

  • You have to pretend it yourself

  • You have to pretend it yourself

(There is also the eliangcs/http-prompt project, which is simply black magic)

aria2c

In one sentence: modern download tool

Advantages:

  • Supports more download methods including magnet links, concurrent downloads, multiple source downloads, etc.

  • Server mode can be installed in the router to achieve remote downloading

Disadvantages:

  • You have to pretend it yourself

  • You have to pretend it yourself

  • You have to pretend it yourself

左手右手慢动作

Personal behavior:

  • wget is generally used to download files

  • curl is generally used to simulate requests and test api

小葫芦

wget: Download tool

  1. For resources with a slow download speed, browsers often assume they are completed before downloading. It is recommended to add -T5

  2. Download HTML documents in batches: wget -T 5 -t 10 -Q 500m -nH -r -E -l inf -k -p -np URL

  3. Batch URL: wget -i URL列表文件

curl: debugging tool

  1. Simple and easy to use, available everywhere

  2. The browser's developer tools support copying as a curl request

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template