Wget: Skip download if file already exists?

前端 未结 2 1824
庸人自扰
庸人自扰 2020-12-30 11:10

Answers to Skip download if files exist in wget? say to use -nc, or --no-clobber, but -nc doesn\'t prevent the sending of the HTTP req

相关标签:
2条回答
  • 2020-12-30 11:50

    The -nc option does what you're asking for, at least in wget 1.19.1.


    On my server, I have a file called index.html which contains links to a.html and b.html.

    $ wget -r -nc http://127.0.0.1:8000/
    

    Server logs show this:

    127.0.0.1 - - [23/Mar/2017 17:51:25] "GET / HTTP/1.1" 200 -
    127.0.0.1 - - [23/Mar/2017 17:51:25] "GET /robots.txt HTTP/1.1" 404 -
    127.0.0.1 - - [23/Mar/2017 17:51:25] "GET /a.html HTTP/1.1" 200 -
    127.0.0.1 - - [23/Mar/2017 17:51:25] "GET /b.html HTTP/1.1" 200 -
    

    Now I remove b.html and run it again:

    $ rm 127.0.0.1\:8000/b.html
    $ wget -r -nc http://127.0.0.1:8000/
    

    Server logs show this:

    127.0.0.1 - - [23/Mar/2017 17:51:38] "GET /robots.txt HTTP/1.1" 404 -
    127.0.0.1 - - [23/Mar/2017 17:51:38] "GET /b.html HTTP/1.1" 200 -
    

    As you can see, only a request for b.html was made.

    0 讨论(0)
  • 2020-12-30 11:58

    It appears you are using incompatible options, I get the following warning on wget 1.16 linux:

    $ wget --no-clobber --convert-links http://example.com
    Both --no-clobber and --convert-links were specified, only --convert-links will be used.
    
    0 讨论(0)
提交回复
热议问题