Created
September 5, 2010 05:29
-
-
Save tjlytle/565773 to your computer and use it in GitHub Desktop.
Calibre Recipe for Doctrine2 Manual
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import string, re | |
from calibre.web.feeds.news import BasicNewsRecipe | |
from calibre.ebooks.BeautifulSoup import Tag, NavigableString | |
class Doctrine2(BasicNewsRecipe): | |
title = 'Doctrine2' | |
__author__ = 'Doctrine PRoject' | |
description = 'Documentation for Doctrine2' | |
INDEX = 'http://www.doctrine-project.org/projects/orm/2.0/docs/reference/en' | |
language = 'en' | |
remove_tags_before = dict(name='div', id='documentation') | |
remove_tags_after = dict(name='div', id='documentation') | |
remove_tags = [dict(name='div', attrs={'class':'chapter-nav'})] | |
no_stylesheets = True | |
def parse_index(self): | |
articles = [] | |
soup = self.index_to_soup(self.INDEX) | |
contents = soup.find('div', attrs={'id':'documentation'}) | |
chapters = contents.find('ul') | |
articles = []; | |
for chapter in chapters.findAll('li'): | |
a = chapter.find('a', href=True) | |
url = a['href'] | |
if url.startswith('/'): | |
url = 'http://www.doctrine-project.org'+url | |
articles.append({'title':self.tag_to_string(a), 'url':url, 'description':self.tag_to_string(a), | |
'date':''}) | |
feeds = [] | |
feeds.append(('Documentation', articles)) | |
return feeds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment