mylamour/blog

How to download Orielly books

Opened this issue · 0 comments

I prefer to use E-book device but not orielly app or web. At the beginning i want to write a spider, but i found we already have a good tools. Also The book download is for personal use only and does not involve copyright issues.

Step 1 : Get Safaribooks tool

git clone https://github.com/lorenzodifuccia/safaribooks
cd safaribooks
python -m venv test
source test/bin/activate
pip install -r requirements.txt -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com/simple

Step 2: Login into Orielly and get cookies

Login into Orielly and go to profile page https://learning.oreilly.com/home/

 javascript:(function(){var output={};document.cookie.split(/\s*;\s*/).forEach(function(pair){pair=pair.split(/\s*=\s*/);output[pair[0]]=pair.splice(1).join('=')});var a=window.document.createElement('a');a.href=window.URL.createObjectURL(new Blob([JSON.stringify(output)],{type:'text/json'}));a.download='cookies.json';document.body.appendChild(a);a.click();document.body.removeChild(a)})()

Step 3: Download it

cp ~/Downloads/cookies.json .
python safaribooks.py 9781492043447

image

Step 4 : Reading

image

Step 5: Convert to PDF

brew install basictex
pandoc infile.epub -o output.pdf