Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚨 LOGIN 🚨 #358

Open
lorenzodifuccia opened this issue Oct 30, 2024 · 2 comments
Open

🚨 LOGIN 🚨 #358

lorenzodifuccia opened this issue Oct 30, 2024 · 2 comments

Comments

@lorenzodifuccia
Copy link
Owner

Can someone please provide a complete and up-to-date guide on exporting cookies from a browser session and using them with safaribooks?

Thank you. Love ❤️

@vbargl
Copy link

vbargl commented Oct 30, 2024

Just bump into this repo like half an hour ago and was able to download some books.
I used js code below from this fork: https://github.com/mauriciospinelli/safaribooks-oreillybooks

console.log(JSON.stringify(document.cookie.split(';').map(c => c.split('=')).map(i => [i[0].trim(), i[1].trim()]).reduce((r, i) => {r[i[0]] = i[1]; return r;}, {})))

@dotemacs
Copy link

dotemacs commented Nov 1, 2024

To make it even more straightforward, for those who are on autopilot and just want to get their book:

  1. Log into O'Reilly
  2. Browse to the book you're interested in
  3. From the URL of the book, extract the book ID, that looks something like: 9781491958698
  4. Open the developer console in your browser and run the above JavaScript in the console tab:
console.log(JSON.stringify(document.cookie.split(';').map(c => c.split('=')).map(i => [i[0].trim(), i[1].trim()]).reduce((r, i) => {r[i[0]] = i[1]; return r;}, {})))
  1. Extract the above output and save it into cookies.json
  2. Then clone this repo: git clone https://github.com/lorenzodifuccia/safaribooks.git
  3. cd safaribooks
  4. Install the relevant dependencies of the project: pip3 install -r requirements.txt
  5. copy/move cookies.json file into the same directory
  6. run python3 safaribooks.py 9781491958698

To make the book look good:

  1. Install Calibre https://calibre-ebook.com/, in order to get the executable ebook-convert
  2. run ebook-convert on the file saved in Books/the-title-of-your-book-ID/ID.epub e.g.
$ ebook-convert "XXXX/safaribooks/Books/Test-Driven Development with Python 2nd Edition (9781491958698)/9781491958698.epub" "XXXX/safaribooks/Books/Test-Driven Development with Python 2nd Edition (9781491958698)/9781491958698_CLEAR.epub"

The first argument is the path to the downloaded ePub, the second is the name you'd like to give to your book. Maybe give it the same name as the title e.g. Test-Driven Development with Python 2nd Edition.epub.
3. install the generated ePub on your desired device/reader

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

No branches or pull requests

3 participants