How to Mirror a Website

February 24, 2017

Ever needed to quickly mirror a website? This can be useful for development and testing, or simply to view websites offline.

Well, here's a rudimentary way to do it with nothing other than wget.

wget --mirror --page-requisites --adjust-extension --no-parent --convert-links http://www.example.com

To make sure you stay on only example.com, add the --domains option.

wget --mirror --page-requisites --adjust-extension --no-parent --convert-links --domains example.com http://www.example.com

Now, wget will do most of the job, but you might still find the mirror incomplete. For example, it can fail to download some CSS and JavaScript resources. For this, something with a stronger parser is needed. One example of such a tool is httrack.

sudo apt-get install httrack
httrack "http://www.example.com/" -O "/tmp/www.example.com" "+*.example.com/*" -v

This should give you a complete mirror.

Related Posts