Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know that wget can fetch a remote page and its dependencies and rewrite the html so that image src attributes reference the newly downloaded images.

I am trying to convert local html files that reference images on the Internet. I'm using

wget --mirror --page-requisites --convert-links \
     --directory-prefix=foo \
     --force-html \

All of the referenced images are downloaded to the appropriate places in foo/ but the src attributes in my_file.html aren't being changed.

share|improve this question
That's a pretty neat use of wget. – womble Jul 7 '11 at 9:19

Try this:

wget --recursive --page-requisites --convert-links --span-hosts http://localhost/some.html
share|improve this answer
This still requires that I run an http server on my local machine just for wget--is there no way to do this using --input-file? – Kevin L. Jul 8 '11 at 14:19
I am afraid not. Wget do not support file:// scheme. --input-file is only to read many urls conveniently in a batch manner. – Casual Coder Jul 8 '11 at 17:13
Many of the images in the file have a relative src, so if I serve it from localhost wget 404's. Apparently the --base flag can only be used with --input-file and --force-html. – Kevin L. Jul 10 '11 at 4:27
Can you serve also the images? Using symlinks you can link to a foo/ directory with images, so your localhost path mimics that in relative src paths. Or you can edit html files and place base tag with appropriate href attribute in <head> section. – Casual Coder Jul 10 '11 at 5:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.