Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I save a web page, programmatically?

I would like to save a web page programmatically.

I don't mean merely save the HTML. I would also like automatically to store all associated files (images, CSS files, maybe embedded SWF, etc), and hopefully rewrite the links for local browsing.

The intended usage is a personal bookmarks application, in which link content is cached in case the original copy is taken down.

like image 724
Joseph Turian Avatar asked Nov 13 '09 22:11

Joseph Turian


2 Answers

Take a look at wget, specifically the -p flag

−p  −−page−requisites
This option causes Wget to download all the files
that are necessary to properly display
a givenHTML  page. Thisincludes such
things as inlined images, sounds, and
referenced stylesheets.

The following command:

wget -p http://<site>/1.html

Will download page.html and all files it requires.

like image 75
Josh Avatar answered Sep 21 '22 00:09

Josh


On Windows: you can run IE as a com object and pull everything out.

On other thing, you can take the source of Mozilla.

In Java, Lobo.

Or commons-httpclient and write a lot of code.

like image 23
bmargulies Avatar answered Sep 23 '22 00:09

bmargulies