How to download images from local html file?

I have a some simple html pages Test.html, test2.html, test3.html. This pages have some links to images:

<img src=""/>

How download all images from this pages automatically, put near the html files and change links in html pages to local images?



Try the command $ wget -F -i <html_file>

This will download every link contained in your <html_file> and put them in the current directory. I recommend you to read the manual of wget ($ man wget) under the OPTIONS section from where i extracted the folowing:

-i file --input-file=file

  Read URLs from a local or external file.  If - is specified as file, URLs are
read from the standard input.  (Use ./- to read from a file literally named -.)

  If this function is used, no URLs need be present on the command line.  If
there are URLs both on the command line and in an input file, those on the
command lines will be the first ones to be retrieved.  If --force-html is not
specified, then file should consist of a series of URLs, one per line.

  However, if you specify --force-html, the document will be regarded as html.
In that case you may have problems with relative links, which you can solve
either by adding "<base href="url">" to the documents or by specifying
--base=url on the command line.

  If the file is an external one, the document will be automatically treated as
html if the Content-Type matches text/html. Furthermore,the file's location
will be implicitly used as base href if none was specified.

and the option:

-F --force-html

  When input is read from a file, force it to be treated as an HTML file.
This enables you to retrieve relative links from existing HTML files on
your local disk, by adding "<base href="url">" to HTML, or using the
--base command-line option.

Also, I recommend you to read the --output-file option from the man page.

This will only handle the download stuff... to make automatic changes on your html file i think you need other tools that shellscripting either does not provide or, if it does, are very complicated to use. I recommend doing a script in python that uses the mentioned command to the downloading stuff, and some python specialized library to process (parse) the file, and make the convenient changes.

Good luck!!!

Need Your Help

Lock UIScrollView on specific page (pagingEnabled)

objective-c ios uiscrollview

I have a UIScrollView with paging enabled, and that works fine.

Html.ActionLink very slow

c# razor

I am using MVC 4 and the Razor View Engine.