Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 \
     --input-file=my_file.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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.