Problem
I’d like to save an image found at https://www.python.org/static/apple-touch-icon-144×144-precomposed.png to my local machine. Now I know how to use the curl command to download distant files from the terminal. So, in order to download the image into my local system, I typed the following into my terminal:
curl https://www.python.org/static/apple-touch-icon-144x144-precomposed.png
However, this does not appear to work, thus there must be another way to use curl to get photos from the Internet. What is the proper method to use this command to download images?
Asked by Manas Chaturvedi
Solution #1
ET made a request. It just returns the contents from the supplied URI. You will not be able to save the file on your local PC.
When you do,
$ curl https://www.python.org/static/apple-touch-icon-144x144-precomposed.png
You will receive binary data in the following format:
|�>�$! <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 ...
You can use the following to save this:
$ curl https://www.python.org/static/apple-touch-icon-144x144-precomposed.png > image.png
to save the unprocessed image data in a file
However, using wget is a simpler option.
$ wget https://www.python.org/static/apple-touch-icon-144x144-precomposed.png
$ ls
.
..
apple-touch-icon-144x144-precomposed.png
Answered by ddavison
Solution #2
Curl -O (capital “o,” not a zero) will do the same thing as wget if you don’t have or wish to install it. For example, wget is missing from my old netbook, and it’s a 2.68 MB installation that I don’t require.
curl -O https://www.python.org/static/apple-touch-icon-144x144-precomposed.png
Answered by jwh
Solution #3
Use uppercase -O if you wish to maintain the original name.
curl -O https://www.python.org/static/apple-touch-icon-144×144-precomposed.png
If you want to save remote file with a different name — use lowercase -o
curl -o myPic.png https://www.python.org/static/apple-touch-icon-144×144-precomposed.png
Answered by daGo
Solution #4
Make a new file called files.txt and paste the URLs into it one by one. Then run the command below.
xargs -n 1 curl -O < files.txt
source: https://www.abeautifulsite.net/downloading-a-list-of-urls-automatically
Answered by korchix
Solution #5
For those who have been denied permission to save a file, here is the command that worked for me:
$ curl https://www.python.org/static/apple-touch-icon-144x144-precomposed.png --output py.png
Answered by George Garchagudashvili
Post is based on https://stackoverflow.com/questions/32330737/ubuntu-using-curl-to-download-an-image