Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'd like to use wget to download a tutorial in a website, but this tutorial is in a specific directory.

Suppose the URL is the tutorial main page http://www.abc.com/aaa/bbb/ccc/index.html.

But the as it contain "continuations" there are other pages I'd like to be interconected that are in directories such as:

http://www.abc.com/aaa/bbb/ccc/ddd/index.html

http://www.abc.com/aaa/bbb/ccc/eee/index.html

http://www.abc.com/aaa/bbb/ccc/fff/ggg/index.html

So, basically I need to download recursively the directories after ccc, but not before, and then convert the links to be used offline. There is any argument to be used with wget that would perform such task?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

Try:

wget -r -np -k -p http://www.site.com/dir/page.html

The args (see man wget) are:

  • r Recurse into links, retrieving those pages too (this has a default max depth of 5, can be set with -l).
  • np Never enter a parent directory (i.e., don't follow a "home" link and mirror the whole site; this will prevent going above ccc in your example).
  • k Convert links relative to local copy.
  • p Get page-requisites like stylesheets (this is an exception to the np rule).

If I remember correctly, wget will create a directory named after the domain and put everything in there, but just in case try it from an empty PWD.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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