Skip to content

Instantly share code, notes, and snippets.

@qwo
Forked from crittermike/wget.sh
Created November 30, 2022 02:07
Show Gist options
  • Save qwo/48f04749a110a30bfcbdad6f2b73ae3e to your computer and use it in GitHub Desktop.
Save qwo/48f04749a110a30bfcbdad6f2b73ae3e to your computer and use it in GitHub Desktop.
Download an entire website with wget, along with assets.
# One liner
wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains yoursite.com --no-parent yoursite.com
# Explained
wget \
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
--restrict-file-names=windows \ # Modify filenames to work in Windows as well.
--domains yoursite.com \ # Do not follow links outside this domain.
--no-parent \ # Don't follow links outside the directory you pass in.
yoursite.com/whatever/path # The URL to download
@qwo
Copy link
Author

qwo commented Nov 30, 2022

trying to make for PDF's and others but buggy, see flags and more behind about why would be failing

One liner

wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains https://sustainability.google,www.gstatic.com --no-parent https://sustainability.google/reports/ -A "*.pdf"

Explained

wget
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
--restrict-file-names=windows \ # Modify filenames to work in Windows as well.
--domains hah.com \ # Do not follow links outside this domain.
--no-parent \ # Don't follow links outside the directory you pass in.
yoursite.com/whatever/path # The URL to download

https://www.computerhope.com/unix/wget.htm
https://unix.stackexchange.com/questions/458634/download-website-with-page-requisites-but-only-images-and-css

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment