我正在尝试镜像一个我管理的站点以用于备份目的。
这是我的 wget 命令:
wget \
--mirror \ # Download the whole site, updating local files as needed.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
--backup-converted \ # Backup original HTML files before converting links
--restrict-file-names=windows \ # Modify filenames to work in Windows as well.
--domains=********.*** \ # Do not follow links outside this domain.
--no-parent \ # Don't follow links outside the directory you pass in.
--append-output=wget.log \ # Send output to log file
--rejected-log=wget-rejected.log \ # separate log file for rejected requests
--reject=SwitchToAdmin,SignOut
--show-progress \ # Show progress bar
--random-wait \ # Roandomize wait time (0.5 - 1.5 * wait)
--wait=2 \ # median wait time in seconds
https://********.*** # The URL to download
结果如下:
--2021-05-03 14:14:20-- http://%20/
Resolving ( )... failed: Temporary failure in name resolution.
wget: unable to resolve host address ‘ ’
--2021-05-03 14:14:20-- http://download/
Resolving download (download)... failed: Temporary failure in name resolution.
wget: unable to resolve host address ‘download’
--2021-05-03 14:14:20-- http://the/
Resolving the (the)... failed: Temporary failure in name resolution.
wget: unable to resolve host address ‘the’
--2021-05-03 14:14:20-- http://whole/
Resolving whole (whole)... failed: Temporary failure in name resolution.
wget: unable to resolve host address ‘whole’
--2021-05-03 14:14:20-- http://site,/
Resolving site, (site,)... failed: Temporary failure in name resolution.
wget: unable to resolve host address ‘site,’
--2021-05-03 14:14:20-- http://updating/
Resolving updating (updating)... failed: Temporary failure in name resolution.
wget: unable to resolve host address ‘updating’
--2021-05-03 14:14:20-- http://local/
Resolving local (local)... failed: Temporary failure in name resolution.
wget: unable to resolve host address ‘local’
--2021-05-03 14:14:20-- http://files/
Resolving files (files)... failed: Temporary failure in name resolution.
wget: unable to resolve host address ‘files’
--2021-05-03 14:14:20-- http://as/
Resolving as (as)... failed: Temporary failure in name resolution.
wget: unable to resolve host address ‘as’
--2021-05-03 14:14:20-- http://needed./
Resolving needed. (needed.)... failed: Temporary failure in name resolution.
wget: unable to resolve host address ‘needed.’
wget.sh: line 9: syntax error near unexpected token `('
wget.sh: line 9: ` --page-requisites \ # Get all assets/elements (CSS/JS/images).'
当我要求 wget 访问 https:// 时,为什么它却尝试访问 http://?
答案1
在 bash 中,\
用于转义以下字符。
它经常被用来(可能这也是你想要的)转义换行符启用多行命令。
wget \
-arg1 \
-arg2
如果要\
转义换行符,则必须将其直接放在其前面,否则它将不起作用:
wget \ # some comment
-arg1 \
-arg2
... 将避开空格并执行以下操作(检查set -x
):
+ wget ' #' some comment
此外,由于您的下一条线路不再连接,您可能会收到类似以下的错误:
`-arg1`: command not found.