如何以编程方式保存网页?

Jos*_*ian 6 caching screen-scraping web-applications html-content-extraction

我想以编程方式保存网页.

我并不仅仅意味着保存HTML.我还想自动存储所有相关文件(图像,CSS文件,可能是嵌入式SWF等),并希望重写本地浏览的链接.

预期用途是个人书签应用程序,其中在原始副本被删除的情况下缓存链接内容.

Jos*_*osh 6

看看wget,特别是-p标志

?p  ??page?requisites
This option causes Wget to download all the ?les
that are necessary to properly display
a givenHTML  page. Thisincludes such
things as inlined images, sounds, and
referenced stylesheets.
Run Code Online (Sandbox Code Playgroud)

以下命令:

wget -p http://<site>/1.html
Run Code Online (Sandbox Code Playgroud)

将下载page.html及其所需的所有文件.