I'd like to mirror a site with wget and convert all the links to the local copies I've downloaded. So far that's easy all I have to do is wget -mk http://site.com

However all of the static media is located in a different domain, if I follow all of the foreign hosts using the -H option it will download that static media files, but it will also download anything else externally linked.

Is there a way to specify 'only download foreign hosts specified in list X'?


See the section in the wget manpage after the --page-requisites option, it has an example:

Links from that page to external documents will not be followed. Actually, to download a single page and all its requisites (even if they exist on separate websites), and make sure the lot displays properly locally, this author likes to use a few options in addition to -p:

wget -E -H -k -K -p http://<site>/<document>
| improve this answer | |
  • I tried the -p option, but still no luck – mountainswhim Feb 25 '10 at 3:37
  • should I take that to mean that you tried the -p option but ignored the section I quoted that tells you that you need a few more options and gives you an example? – Justin Feb 25 '10 at 4:41
  • exactly, I'm already using -k. -K does nothing more but backup files before converting them and -E just renames extensions if needed. As for -H, you can see my problem with that in my initial question. – mountainswhim Feb 25 '10 at 5:08

Add -Dwww.domain.com,static.domain.com with your equivalent domains.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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