https://xingyys.tech/%E4%B8%8B%E8%BD%BDoreilly%E7%94%B5%E5%AD%90%E4%B9%A6/
1. 安裝
首先下載 safaribooks 工具墓律。
$ git clone https://github.com/lorenzodifuccia/safaribooks.git
Cloning into 'safaribooks'...
$ cd safaribooks/
$ pip3 install -r requirements.txt
OR
$ pipenv install && pipenv shell
2. 使用
-
帳號(hào)密碼下載
獨(dú)立(非關(guān)聯(lián)) O'Reilly 帳號(hào)適用
python3 safaribooks.py --cred "account_mail@mail.com:password01" XXXXXXXXXXXXX
其中 XXXXXXXXXXXXX 表示電子書的 ID。例如電子書頁(yè)面 https://learning.oreilly.com/videos/python-fundamentals/9780135917411/ 的 ID 就是 9780135917411倾剿。
-
使用本地 cookies.json 文件下載
O’Reilly 賬號(hào)為公司關(guān)聯(lián)賬號(hào)適用
下載
先在瀏覽器中登錄 O’Reilly 頁(yè)面薪捍,轉(zhuǎn)到這個(gè)首頁(yè) https://learning.oreilly.com/profile/黑毅。
打開瀏覽器的開發(fā)者模式带迟。Chrome 下點(diǎn)擊右上三點(diǎn)券盅,選擇More tools
-> Developer tools
鞭执,選擇Console
欄霸褒。
在 Console
下執(zhí)行命令:
javascript:(function(){var output = {};document.cookie.split(/\s*;\s*/).forEach(function(pair) {pair = pair.split(/\s*=\s*/);output[pair[0]]=pair.splice(1).join('=');});console.log(JSON.stringify(output));})();
將輸出的信息保存到 safaribooks
目錄下的 cookies.json
文件中伴找。
執(zhí)行以下命令下載電子書:
python3 safaribooks.py XXXXXXXXXXXXX
輸出結(jié)果為:
██████╗ ██████╗ ██╗ ██╗ ██╗██████╗
██╔═══██╗ ██╔══██╗██║ ╚██╗ ██╔╝╚════██╗
██║ ██║ ██████╔╝██║ ╚████╔╝ ▄███╔╝
██║ ██║ ██╔══██╗██║ ╚██╔╝ ??══╝
╚██████╔╝ ██║ ██║███████╗██║ ██╗
╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[-] Successfully authenticated.
[*] Retrieving book info...
[-] Title: A Tour of C++, 3rd Edition
[-] Authors: Bjarne Stroustrup
[-] Identifier: 9780136823575
[-] ISBN: 9780136823575
[-] Publishers: Addison-Wesley Professional
[-] Rights:
[-] Description: In A Tour of C++, Third Edition, Bjarne Stroustrup provides an overview of ISO C++, C++20, that aims to give experienced programmers a clear understanding of what constitutes modern C++. Featuring carefully crafted examples and practical help in getting started, this revised and updated edition concisely covers most major language features and the major standard-library components needed for effective use.Stroustrup presents C++ features in the context of the programming styles they support, suc...
[-] Release Date: 2022-09-30
[-] URL: https://learning.oreilly.com/library/view/a-tour-of/9780136823575/
[*] Retrieving book chapters...
[*] Output directory:
/home/liji/git/safaribooks/Books/A Tour of C__ 3rd Edition (9780136823575)
[-] Downloading book contents... (48 chapters)
[#####################################################################] 100%
[-] Downloading book CSSs... (1 files)
[#####################################################################] 100%
[-] Downloading book images... (596 files)
[#####################################################################] 100%
[-] Creating EPUB file...
[*] Done: /home/liji/git/safaribooks/Books/A Tour of C__ 3rd Edition (9780136823575)/9780136823575.epub
If you like it, please * this project on GitHub to make it known:
https://github.com/lorenzodifuccia/safaribooks
e don't forget to renew your Safari Books Online subscription:
https://learning.oreilly.com
[!] Bye!!
3. 格式轉(zhuǎn)化
下載的電子書為 epub
格式,如果需要其他格式時(shí)废菱,可以借用 calibre 工具來轉(zhuǎn)化技矮。