Make wget download page resources on a different domain

How do you use wget to download an entire site (domain A) when its resources are on another domain, (domain B)?
I've tried:
wget -r --level=inf -p -k -E --domains=domainA,domainB http://www.domainA


wget --recursive --level=inf --page-requisites --convert-links --html-extension \
     --span-hosts=domainA,domainB url-on-domainA

UPDATE: I remember the command above worked for me in the past (that was 2010 and I was using GNU Tools for Windows back then); however I had to change it to the following when I wanted to use it today:

wget --recursive --level=inf --page-requisites --convert-links \
     --adjust-extension --span-hosts --domains=domainA,domainB domainA

The shorthand for that would be: wget -rEDpkH -l inf domainA,domainB domainA

  • -r = --recursive
  • -l <depth> = --level=<depth>
  • -E = --adjust-extension
  • -p = --page-requisites
  • -K = --backup-converted
  • -k = --convert-links
  • -D <domain-list> = --domains=<domain-list>
  • -H = --span-hosts
  • -np = --no-parent
  • -U <agent-string> = --user-agent=<agent-string>

GNU Wget Manual: https://gnu.org/software/wget/manual/wget.html


wget --recursive --level=inf --page-requisites --convert-links --html-extension -rH -DdomainA,domainB domainA