Ubuntu:使用curl下载图像 [英] Ubuntu: Using curl to download an image

查看:93
本文介绍了Ubuntu:使用curl下载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从以下链接下载图像:https://www.python.org/static/apple-touch-icon-144x144-precomposed.png到我的本地系统.现在,我知道curl命令可用于通过终端下载远程文件.因此,我在终端中输入了以下内容,以便将图像下载到本地系统中:

I want to download an image accessible from this link: https://www.python.org/static/apple-touch-icon-144x144-precomposed.png into my local system. Now, I'm aware that the curl command can be used to download remote files through the terminal. So, I entered the following in my terminal in order to download the image into my local system:

curl https://www.python.org/static/apple-touch-icon-144x144-precomposed.png

但是,这似乎不起作用,因此很明显,还有其他方法可以使用curl从Internet下载图像.使用此命令下载图像的正确方法是什么?

However, this doesn't seem to work, so obviously there is some other way to download images from the Internet using curl. What is the correct way to download images using this command?

推荐答案

curl将执行GET请求.它只会从指定的URI返回数据.不能将文件本身检索到本地计算机上.

curl without any options will perform a GET request. It will simply return the data from the URI specified. Not retrieve the file itself to your local machine.

这样做的时候,

$ curl https://www.python.org/static/apple-touch-icon-144x144-precomposed.png

您将收到二进制数据:

                   |�>�$! <R�HP@T*�Pm�Z��jU֖��ZP+UAUQ@�
��{X\� K���>0c�yF[i�}4�!�V̧�H_�)nO#�;I��vg^_ ��-Hm$$N0.
���%Y[�L�U3�_^9��P�T�0'u8�l�4 ...

为了保存此内容,您可以使用:

In order to save this, you can use:

$ curl https://www.python.org/static/apple-touch-icon-144x144-precomposed.png > image.png

将原始图像数据存储在文件中.

to store that raw image data inside of a file.

不过,更简单的方法是只使用wget.

An easier way though, is just to use wget.

$ wget https://www.python.org/static/apple-touch-icon-144x144-precomposed.png
$ ls
.
..
apple-touch-icon-144x144-precomposed.png

这篇关于Ubuntu:使用curl下载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆