Html 下载网页和依赖项,包括 css 图像

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1581551/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 01:04:08  来源:igfitidea点击:

download webpage and dependencies, including css images

htmlcssimagedownload

提问by hoju

Often I need to download a webpage and then edit it offline. I have tried a few tools and the main feature they lack is downloading images referenced in the CSS files.

我经常需要下载一个网页,然后离线编辑它。我尝试了一些工具,但它们缺少的主要功能是下载 CSS 文件中引用的图像。

Is there a tool (for Linux) that will download everything so that the webpage will render the same offline (excluding AJAX)?

是否有工具(适用于 Linux)可以下载所有内容,以便网页在离线时呈现相同的内容(不包括 AJAX)?

回答by ax.

wget --page-requisites http://example.com/your/page.html

This optioncauses Wget to download all the files that are necessary to properly display a given html page. This includes such things as inlined images, sounds, and referenced stylesheets.

此选项使 Wget 下载正确显示给定 html 页面所需的所有文件。这包括内联图像、声音和引用的样式表等内容。

EDIT: meder is right: stock wget does not parse and download css images. There is, however, a patch that adds this feature: [1, 2]

编辑:meder 是对的:stock wget 不解析和下载 css 图像。但是,有一个补丁添加了此功能:[ 1, 2]

UPDATE: The patch mentioned above has been merged into wget 1.12, released 22-Sep-2009:

更新:上面提到的补丁已合并到 wget 1.12 中,于 2009 年 9 月 22 日发布:

** Added support for CSS. This includes:
 - Parsing links from CSS files, and from CSS content found in HTML
   style tags and attributes.
 - Supporting conversion of links found within CSS content, when
   --convert-links is specified.
 - Ensuring that CSS files end in the ".css" filename extension,
   when --convert-links is specified.

回答by Jonathan

It's possible to do this through Firefox, see this form

可以通过 Firefox 执行此操作,请参阅此表单

  1. Right click
  2. View page info
  3. Select media tab
  4. Highlight all files
  5. Save as
  1. 右键点击
  2. 查看页面信息
  3. 选择媒体选项卡
  4. 突出显示所有文件
  5. 另存为

Reference - http://www.webdeveloper.com/forum/showthread.php?t=212610

参考 - http://www.webdeveloper.com/forum/showthread.php?t=212610

回答by Everette Mills

I ran into the same problem the other day working for a client. Another tool that works really well is HTTrack. The software is available in a commandline verison for both windows and Linux. For Linux they prebuilt packages for most of the more common operating systems found here

前几天我为客户工作时遇到了同样的问题。另一个非常有效的工具是HTTrack。该软件可用于 Windows 和 Linux 的命令行版本。对于 Linux,他们为这里找到的大多数更常见的操作系统预先构建了软件包

For my purposes it worked better than wget with some of the added features/switches that fix links inside the html file.

出于我的目的,它比 wget 更好地工作,其中包含一些修复 html 文件内链接的附加功能/开关。

回答by Tran Dang Khoa

wget is a great choice for you. Just for more information, the wget version on windows at this time there is no official release on gnu for wget version 1.12. The current version is 1.11

wget 是您的绝佳选择。只是为了了解更多信息,windows 上的wget 版本此时gnu 上没有正式发布wget 1.12 版。当前版本是 1.11

wget version 1.11 cannot download images/fonts in css files. Fortunately, you can find a build of 1.14 from this page. It fixed these problems.

wget 1.11 版无法下载 css 文件中的图像/字体。幸运的是,您可以从此页面找到 1.14 版本。它解决了这些问题。

http://opensourcepack.blogspot.com/2010/05/wget-112-for-windows.html

http://opensourcepack.blogspot.com/2010/05/wget-112-for-windows.html

回答by Marco

The current version of Opera (12) allows to save a page as 'HTML with images'.

当前版本的 Opera (12) 允许将页面保存为“带有图像的 HTML”。

Thereby Opera also downloads images which are referenced in the CSS files and adapts the image URLs in the CSS accordingly.

因此,Opera 还会下载 CSS 文件中引用的图像,并相应地调整 CSS 中的图像 URL。

回答by LiveSource

In Firefox:

在 Firefox 中:

File->Save Page As->Web Page, Complete

文件->页面另存为->网页,完成

Saves all javascript and images and css. Nothing else required :)

保存所有 javascript 和图像以及 css。没有其他要求:)

回答by OscarRyz

wget