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 url = window.location; var title = document.getElementById("hibtext").textContent.match("Humble Book.*")[0].split(":")[1].trim(); var date = new Date(); var year = date.getFullYear(); var month = ('0' + (date.getMonth()+1)).slice(-2); var dir = "Humble Book Bundle - " + year + "-" + month + " - " + title; var dl_links = document.querySelectorAll('[href^=""]'); var dl_list = ""; for (i = 0; i < dl_links.length; ++i){ dl_list += dl_links[i].href + "\n"; }; document.documentElement.innerHTML = "<pre>mkdir \"" + dir + "\"<br>cd \"" + dir + "\"<br>echo \"" + url + "\" > bundle_downloadpage.txt<br>cat << EOI > bundle_links.txt<br>" + dl_list + "EOI<br><br>xargs -n 1 curl -JLO < bundle_links.txt<br>for i in *\\?*; do mv -vf \"${i}\" \"${i%%\\?*}\"; done</pre>";})();

This code gets some information about the bundle and loops through all download links on the webpage that start with “” and prints commands on the page which can be executed to easily download all books:

Execute these commands in a bash shell and it will automatically create a new directory containing all the ebooks!

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


Leave a Comment