下载具有页面要求但仅包含图像和 CSS 的网站

下载具有页面要求但仅包含图像和 CSS 的网站

我正在使用一个wget命令来下载包含所有资产、必需品的整个网页,并将其保存到自定义文件夹以供以后使用。

我的实际代码:

$ wget --adjust-extension --span-hosts --convert-links --page-requisites \
 --no-directories --restrict-file-names=windows --no-parent \
 --user-agent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"\
 ‐‐execute robots=off --limit-rate 400k --directory-prefix=elbache \
 ‐‐output-document=index.html http://www.bachecubano.com/celulares

现在一切都很好,但我想减少--page-requisites到只有 CSS 和图像(我不需要 .JS 文件)。如果我不加载 .js 资源,下载的页面可以减少近 40%,这对于我的目的来说不是必需的。

如何配置wget为仅接受.css 和 /images但不是 *.js 文件?

答案1

wget手册页:

   -A acclist --accept acclist
   -R rejlist --reject rejlist
       Specify comma-separated lists of file name suffixes or patterns to 
       accept or reject. Note that if any of the wildcard characters, 
       *, ?, [ or ], appear in an element of acclist or rejlist, it will be
       treated as a pattern, rather than a suffix.

因此,您可以将以下开关添加到已有的开关中:

-A css,png,jpg,gif,jpeg

笔记:您必须使用它并找出该特定站点使用的图像格式。

相关内容