Calibre-e-book Management is a very powerful ebook management software that can open and convert ebooks in various formats, can crawl news to local reading, allow users to customize news feeds, You can write your own recipe Let it crawl the content on the Web page and generate ebook, take advantage of this feature I will Liaoche Teacher's Python tutorial and git tutorial made an epub ebook, using the Firefox Epubreader plugin can open reading on the computer, Mobile phone in more like reading can also, this experience for vacation home without network but want to learn the students are still good.
Recipe uses Python to write, with the learning of Python to acquire learning resources, strengthen practice, the operation is very simple, download Calibre-e-book management know, calibre also for the writing of recipe provides API documentation
Here is the recipe code to crawl the Python tutorial
#!/usr/bin/env python#Vim:fileencoding=utf-8 from __future__ Importunicode_literals, Division, Absolute_import, Print_function fromCalibre.web.feeds.newsImportBasicnewsrecipeclassLiaoxuefeng_python (basicnewsrecipe): Title='Liaoche Python Tutorials'Description='Python Tutorials'Max_articles_per_feed= 200Url_prefix='http://www.liaoxuefeng.com'no_stylesheets=True keep_only_tags= [{'ID':'Main'}] Remove_tags=[{'class':'X-wiki-info'}] Remove_tags_after=[{'class':'x-wiki-content x-content'}] defget_title (self, link):returnLink.contents[0].strip ()defParse_index (self): Soup= Self.index_to_soup ('http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000') Div= Soup.find ('Div', {'class':'X-wiki-tree'}) Articles= [] forLinkinchDiv.findall ('a'): til=self.get_title (link) URL= Self.url_prefix + link['href'] a= {'title': Til,'URL': URL} articles.append (a) tutorial= [('Liaoche Python Tutorials', articles)] returnTutorial
Crawl git tutorial just need to change the Parse_index method in the Python tutorial link to the Git tutorial link, the finished product in this tutorial
Making ebooks with calibre and python---python and git tutorials