Humble Book Bundle Download Bookmarklet

Humble Book Bundle [1] has often very cool books about IT, hacking, security, programming, Linux, Unix, science and other geeky stuff. Sadly there is no reliable way to download all books. This post shows how you can download all books in a quick and reliable way using a bookmarklet.


Of course, first you need to buy the Humble Book Bundle.

For this example, I use the “Secure Your Stuff by Apress” Humble Book Bundle:

The Goal

I want to download all the books in a simple and reliable way.

The Problem

There are two problems:

  • Clicking on all PDF and EPUB buttons takes too much time and is annoying.
  • The “Bulk Download” button does not work in a reliable way. Often, downloads are missed and it has to be clicked several times until all books are downloaded. This is the same behavior for direct links and the BitTorrent links.

The Solution

A bookmarklet [2] can be used to extract all direct download links from the website. This list can then be used to download all books.

Create a new bookmark:

Paste the following code into the Location field:

javascript:(function(){var dl_links = document.querySelectorAll('[href^=""]'); var dl_list = ""; for (i = 0; i < dl_links.length; ++i){ dl_list += dl_links[i].href + "\n"; }; console.log(dl_list);alert("See console for link list");})();

This code loops through all download links on the webpage that start with “” and prints the list of these links in the JavaScript console.

When you click on the bookmarklet, you will now get a list of all links in the JavaScript console:

Copy them into a file, e.g. links.txt:

Finally download all these files using e.g. curl:

$ xargs -n 1 curl -JLO < links.txt

Curl now downloads all these files:

Some files might contains the GET parameters in the filename:

These can be removed using this oneliner [3]:

$ for i in *\?*; do mv -vf "${i}" "${i%%\?*}"; done

You have now all books with the correct name in your directory:

Now you just need some time to read all these books ­čśë


Leave a Comment