Download Files from a Directory with wget

wget is useful when you need to download files from a web directory or mirror a simple documentation page for offline use.

Example

This command recursively downloads the linked page and the files needed to view it locally:

wget -H -r --level=1 -k -p https://tldp.org/HOWTO/Serial-Programming-HOWTO/

Options used

  • -r or --recursive: enable recursive download.
  • --level=1: limit recursion depth to one level.
  • -k or --convert-links: convert links so downloaded HTML points to local files.
  • -p or --page-requisites: download images, CSS and other files needed to display the page.

Be careful with recursive downloads on large sites. Start with a low recursion level and check what will be downloaded before increasing the depth.

Leave a Comment