Skip to content

Read the awesome articles on geeksforgeeks.org and leetcode.com on your Kindle or iPad, without distraction

Notifications You must be signed in to change notification settings

angadgadre/geeksforgeeks-as-books

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Geeksforgeeks/leetcode Articles As Books

Have you ever wished you could read the awesome stuff on geeksforgeeks.org or leetcode.com offline right on your iPad? Or on your Kindle/Kindle App? Well, now you have it. Look under the directory goodies and do the world some good with your algorithmic prowess 😄

Here's how the books look like in the iBooks App and Kindle App on my iPad. Kindle hasn't been tested.

Book covers Book covers are made of word clouds based on the book content using word_cloud

On Ipad

On Kindle App

Books

Right now we have 16 books under goodies/geeksforgeeks and one book under goodies/leetcode

Tools

Want to create a book from the geeksforgeeks site yourself? No problem. But you'll need some tools to get started. Apart from Python 2 you also need those.

1. Scrapy

Scrapy is used to download webpages from geeksforgeeks and leetcode. It makes it super easy to do so with its rules.

Install it with pip install scrapy

2. Boilerpipy

So you have the html files locally. But those html files have many other stuff you don't want. You only want... goodies. No problem. Check out boilerpipy, it can remove all the unnecessary stuff like header and comments, leaving you with only the article itself. It has the functionality of Pocket or Readability you might be familiar with. However, I've found that it also removes the title of an article sometimes.

3. Pandoc

Pandoc is just super. It's used here to convert html files or markdown files to epub files. But it can do so much more. It's also super easy to generate pdf versions of the books if you want. You should definitely check it out.

4. Kindlegen

You'll need kindlegen to generate mobi files so you can read on your beloved Kindle or Kindle App. Download it from the linked Amazon webpage and install.

You just need to use kindlegen awesome.epub and it'll give you a file called awesome.mobi. Awesome, right?

How To

1. Crawling with Scrpay

Go to the geeksforgeeks subdirectory and run commands like scrapy crawl geeksforgeeks -a category=category -a name=name.

For example, running scrapy crawl geeksforgeeks -a category=tag -a name=pattern-searching will crawl from the page http://www.geeksforgeeks.org/tag/pattern-searching/. category and name are two arguments our spider takes. On geeksforgeeks, things can be organized by tag or category. Specify the category/tag and the name, Scrapy will do the rest for you.

2. Generate a book

Following the example in 1, now go into the geeksforgeeks-books subdirectory and you should be able to find a directory called pattern-searching. Now run python generate_book.py pattern-searching. It will first clean the html files, concatenate the cleaned files into one, then use pandoc to create an epub file from the markdown file. In the end a mobi file is created using kindlegen.

Yay! Done!

To Do

Style the books

Style the books better. Those books are essentially styled via css. Therefore styling <pre> tag, for instance, will style the code of the epub books.

Contribute

I've only worked on this project for a few days since I had the idea. It has huge room to improve. It's the first time I used Scrapy and pandoc.

You can contribute in many ways. Besides contributing code to this project. You are more than welcome to contribute in the following ways.

Book

Every tag or category on geeksforgeeks can be turned into a book. So you are welcome to add more books.

Styles

The style for generating epub books is under styles subdirectory. epub books are styled via css. Welcome to submit your stylesheets.

License

The content in the books doesn't belong to me. I created the books so other people and me can read them offline on iPad or Kindle, and for a better reading experience.

The content on geeksforgeeks.org is licensed under Creative Commons Attribution-NonCommercial-NoDerivs 2.5 India. See the license here

The content on leetcode belongs to the site.

The code in this project is licensed under Apache License, Version 2.0. See the license here

Authors

Jing Zhou, gnijuohz at gmail.com

About

Read the awesome articles on geeksforgeeks.org and leetcode.com on your Kindle or iPad, without distraction

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • CSS 73.0%
  • Python 27.0%