Ubuntu: Using curl to download an image

前端 未结 5 1706
隐瞒了意图╮
隐瞒了意图╮ 2021-01-31 01:17

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

相关标签:
5条回答
  • 2021-01-31 01:52

    Create a new file called files.txt and paste the URLs one per line. Then run the following command.

    xargs -n 1 curl -O < files.txt
    

    source: https://www.abeautifulsite.net/downloading-a-list-of-urls-automatically

    0 讨论(0)
  • 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.

    When you do,

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

    You will receive binary data:

                       |�>�$! <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.

    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
    
    0 讨论(0)
  • 2021-01-31 02:04

    For ones who got permission denied for saving operation, here is the command that worked for me:

    $ curl https://www.python.org/static/apple-touch-icon-144x144-precomposed.png --output py.png
    
    0 讨论(0)
  • 2021-01-31 02:06

    For those who don't have nor want to install wget, curl -O (capital "o", not a zero) will do the same thing as wget. E.g. my old netbook doesn't have wget, and is a 2.68 MB install that I don't need.

    curl -O https://www.python.org/static/apple-touch-icon-144x144-precomposed.png
    
    0 讨论(0)
  • 2021-01-31 02:18

    If you want to keep the original name — use uppercase -O

    curl -O https://www.python.org/static/apple-touch-icon-144x144-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-144x144-precomposed.png

    0 讨论(0)
提交回复
热议问题