linux使用curl命令_如何使用curl从Linux命令行下载文件

  • Post author:
  • Post category:linux


linux使用curl命令

linux使用curl命令

A terminal window on a Ubuntu-style Linux desktop.

Fatmawati Achmad Zaenuri/Shutterstock


Fatmawati Achmad Zaenuri / Shutterstock

The Linux

curl

command can do a whole lot more than download files. Find out what

curl

is capable of, and when you should use it instead of

wget

.

Linux

curl

命令除了下载文件外,还可以做更多的事情。 找出

curl

的功能,以及何时使用它而不是

wget

curl vs. wget:有什么区别?

(

curl vs. wget : What’s the Difference?

)

People often struggle to identify the relative strengths of the

wget

and

curl

commands. The commands do have some functional overlap. They can each retrieve files from remote locations, but that’s where the similarity ends.

人们通常很难确定

wget



curl

命令的相对优势。 这些命令确实有一些功能重叠。 他们每个人都可以从远程位置检索文件,但这就是相似性结束的地方。


wget

is a

fantastic tool for downloading content and files

. It can download files, web pages, and directories. It contains intelligent routines to traverse links in web pages and recursively download content across an entire website. It is unsurpassed as a command-line download manager.


wget



下载内容和文件



绝佳工具

。 它可以下载文件,网页和目录。 它包含智能例程,可遍历网页中的链接并在整个网站上递归下载内容。 作为命令行下载管理器,它无与伦比。


curl

satisfies

an altogether different need

. Yes, it can retrieve files, but it cannot recursively navigate a website looking for content to retrieve. What

curl

actually does is let you interact with remote systems by making requests to those systems, and retrieving and displaying their responses to you. Those responses might well be web page content and files, but they can also contain data provided via a web service or API as a result of the “question” asked by the curl request.


curl


完全

满足

了不同的需求

。 是的,它可以检索文件,但是不能递归地浏览网站以查找要检索的内容。

curl

实际作用是通过向远程系统发出请求,并检索和显示它们对您的响应,从而与远程系统进行交互。 这些响应很可能是网页内容和文件,但是由于curl请求提出的“问题”,它们也可能包含通过Web服务或API提供的数据。

And

curl

isn’t limited to websites.

curl

supports over 20 protocols, including HTTP, HTTPS, SCP, SFTP, and FTP. And arguably, due to its superior handling of Linux pipes,

curl

can be more easily integrated with other commands and scripts.

而且

curl

不仅限于网站。

curl

支持20多种协议,包括HTTP,HTTPS,SCP,SFTP和FTP。 可以说,由于其对Linux管道的出色处理,

curl

可以更轻松地与其他命令和脚本集成。

The author of

curl

has a webpage that

describes the differences he sees

between

curl

and

wget

.


curl

的作者提供了一个网页,该网页

描述了他看到的


curl



wget

之间

的差异

安装卷发

(

Installing curl

)

Out of the computers used to research this article, Fedora 31 and Manjaro 18.1.0 had

curl

already installed.

curl

had to be installed on Ubuntu 18.04 LTS. On Ubuntu, run this command to install it:

在用于研究本文的计算机中,Fedora 31和Manjaro 18.1.0已经安装了

curl



curl

必须在Ubuntu 18.04 LTS上安装。 在Ubuntu上,运行以下命令进行安装:

sudo apt-get install curl
sudo apt-get install curl in a terminal window

卷曲版本

(

The curl Version

)

The

--version

option makes

curl

report its version. It also lists all the protocols that it supports.


--version

选项使

curl

报告其版本。 它还列出了它支持的所有协议。

curl --version
curl --version in a terminal window

检索网页

(

Retrieving a Web Page

)