Skip to content

Instantly share code, notes, and snippets.

@edwardchanjw
Forked from SgtPooki/getFreeOreillyBooks.js
Created September 8, 2017 01:54
Show Gist options
  • Save edwardchanjw/496e4687a8bd070c373eeacf4dd5835e to your computer and use it in GitHub Desktop.
Save edwardchanjw/496e4687a8bd070c373eeacf4dd5835e to your computer and use it in GitHub Desktop.
Script to automatically download free ebooks listed on oreilly
/*
Just paste into your console.. or make a tampermonkey/greasemonkey script out of it.
Only tested in Chrome. Be careful.. three tabs are opened per book.
If a books image is not removed, you'll need to try to download that book yourself.
Use this script (enter into the console of your browser) on the following pages:
http://www.oreilly.com/programming/free/
http://www.oreilly.com/business/free/
http://www.oreilly.com/data/free/
http://www.oreilly.com/iot/free/
http://www.oreilly.com/security/free/
http://www.oreilly.com/web-platform/free/
http://www.oreilly.com/webops-perf/free/
*/
var jq = document.createElement('script');
jq.src = "https://code.jquery.com/jquery-latest.min.js";
jq.onload= function() {
var $downloadableBooks = $('a[href*="/free/"]').filter(function(i, el){
return $(el).find('img').length > 0;
});
var wgetList = '';
$downloadableBooks.each(function (i, el) {
var link = $(el).attr('href').split('?')[0];
if (link.indexOf('.csp') < 0) {
return;
}
$(el).remove();
link = link.split('.');
link.splice(-1,1);
$(['mobi', 'epub', 'pdf']).each(function(i2, format) {
var bookUrl = [].concat(link, format).join('.').replace('/free/', '/free/files/');
wgetList += 'wget ' + bookUrl + '\n';
window.open(bookUrl);
});
});
console.log(wgetList);
}
document.getElementsByTagName('head')[0].appendChild(jq);
@edwardchanjw
Copy link
Author

Just to keep track some of the free media
Maybe chimera oreilly also

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