Created
August 12, 2020 14:44
-
-
Save pniedzwiedzinski/d892fa4ad882468f32d87178718436bd to your computer and use it in GitHub Desktop.
Download websites as pdfs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env nix-shell | |
#! nix-shell -p chromium pdftk -i sh | |
## Download webpages into pdfs | |
## | |
## Usage | |
## ----- | |
## | |
## Put list of links into /tmp/urls and run script. | |
[ -f /tmp/result ] || mkdir -p /tmp/result | |
for url in `cat /tmp/urls`; do | |
name=`echo $url | sed 's/.*\/\(.*\)\/$/\1/'` | |
chromium --headless --print-to-pdf=/tmp/$name.pdf $url > /dev/null | |
# OPTIONAL: Remove first and last page (header, footer) | |
pdftk /tmp/$name.pdf cat 2-r2 output /tmp/result/$name.pdf > /dev/null | |
echo "Saved to /tmp/result" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment