Showing posts with label command wget. Show all posts
Showing posts with label command wget. Show all posts

Wednesday, November 11, 2009

How to download an entire website using wget

Sometimes you may want to download an entire website.If you are using a linux machine - this is an incredibly easy thing to do.

Just type in the following command into your terminal and hit Enter.

sudo wget -r --no-parent http://www.technicalinterviewquestions.net/

You will of course have to replace http://www.technicalinterviewquestions.net/
with the url of the website that you wish to download.




For those of you who want a more detailed understanding of the command - read on:

sudo wget -r --no-parent http://www.technicalinterviewquestions.net/

sudo allows a permitted user to execute a command as the superuser or another user, as specified in the sudoers file.

sudo wget -r --no-parent http://www.technicalinterviewquestions.net/

wget can follow links in HTML pages and create local versions of remote web sites, fully recreating the directory structure of the original site. This is sometimes referred to as ``recursive downloading.'' While doing that, wget respects the Robot Exclusion Standard (/robots.txt). wget can be instructed to convert the links in downloaded HTML files to the local files for offline viewing.

sudo wget -r --no-parent http://www.technicalinterviewquestions.net/

-r
--recursive
Turn on recursive retrieving.


sudo wget -r --no-parent http://www.technicalinterviewquestions.net/

--no-parent
Do not ever ascend to the parent directory when retrieving recursively. This is a useful option, since it guarantees that only the files below a certain hierarchy will be downloaded.


sudo wget -r --no-parent http://www.technicalinterviewquestions.net/

This is the url of the website which we wish to download.Since I wanted to download the entire site I gave the base url as the argument.However if I had just wanted to download only a particular section of the website (say, archives) then I would have entered the command as:

sudo wget -r --no-parent http://www.technicalinterviewquestions.net/archives/


More information about this command is available here:
http://linux.about.com/od/commands/l/blcmdl1_wget.htm