如何使用 wget 下载整个网站以供离线使用
以下是使用 wget 下载整个网站并使其可离线访问的简单步骤。
💡 Wget是一个命令行实用程序,用于使用 HTTP、HTTPS 和 FTP 协议检索文件。
如何安装 Wget
Wget 随大多数 Unix/Linux 系统一起提供,但如果您没有安装,以下是获取方法。
使用命令 →
在 Mac 上:
brew install wget
在Linux系统上:
sudo apt-get install wget
使用 Wget 下载网站:
在终端中输入此命令
wget -m -p -E -k -np https://example.com
选项详解:
-m, --mirror Turns on recursion and time-stamping, sets infinite
recursion depth, and keeps FTP directory listings.
-p, --page-requisites Get all images, etc. needed to display HTML page.
-E, --adjust-extension Save HTML/CSS files with .html/.css extensions.
-k, --convert-links Make links in downloaded HTML point to local files.
-np, --no-parent Dont ascend to the parent directory when retrieving
recursively. This guarantees that only the files below
a certain hierarchy will be downloaded. Requires a slash
at the end of the directory, e.g. example.com/foo/.
有关 wget 使用的更多详细信息,请查看手册页。
文章来源:https://dev.to/jjokah/how-to-download-an-entire-website-for-offline-usage-using-wget-2lli