Using Wget to Download a Local Copy of a Website22 May 2016
Why would you want a local copy?
- Developing and testing widgets: You’re creating a widget for a client and don’t have direct access to edit their website. You can download a copy and install your widget for testing before deployment.
- Working offline: You’re about to be without internet connection and still want to work on a website that stored remotely on a CMS.
- Web scraping: You want to download a website to extract data.
Wget is a fancy tool used to downloads files. This is the tool we’re going to use to download a local copy of a website. It has a ton of features that you can check out here. It comes pre-installed on most *nix systems and is available on OS X and Windows as well.
If you’re on OS X like I am you can download Wget via Homebrew.
|adjust-extension||Add ".html" to the end of the local filename if the content-type is html/xhtml and the .html extension is not present.|
|convert-links||Make links suitable for local viewing. This will modify links within the HTML so that they point to local assets.|
|mirror||Recursively download files with infinite depth. Use this option if you want to download the entire website.|
|no-parent||Don't ascend to the parent directly. This is useful if you only want to download a subset of a website such as dead-simple.sorrentino.io/projects|
|page-requisites||Download all assets necessary to view the site offline. This tells Wget to download images, sounds, stylesheets, etc so that your local copy is complete.|
You should be able to open the index.html file in your browser and interact with the local copy of the website.