Skip to content

Instantly share code, notes, and snippets.

@rbf
Last active August 17, 2017 05:00
Show Gist options
  • Save rbf/7e68eba13a6e6a4c0e058748c48a96f4 to your computer and use it in GitHub Desktop.
Save rbf/7e68eba13a6e6a4c0e058748c48a96f4 to your computer and use it in GitHub Desktop.
Script to batch download Free Programming Ebooks form O'Reilly Media (see https://pinboard.in/u:rbf/b:5ef50c7b00de)
#!/bin/bash
# Download O'Reilly free programming ebooks
# SOURCE: https://pinboard.in/u:rbf/b:5ef50c7b00de
# SOURCE: https://www.reddit.com/r/programming/comments/6do7ih/free_programming_ebooks/di4ml1r/
# Fail fast
set -eox pipefail
section=("data" "security" "business" "web-platform" "webops" "programming" "iot" "design")
for i in "${section[@]}"
do
echo Processing category ${i}...
mkdir $i || true
cd $i
curl http://www.oreilly.com/$i/free/ | tr '"' \\n | grep http | grep free | cut -d "?" -f1 | sed 's/free/free\/files/' | sed 's/\.csp/\.pdf/' | grep .pdf | xargs -n1 -P4 curl -sLO --compressed || true
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment