Skip to content

Instantly share code, notes, and snippets.

@tjlytle
Created September 5, 2010 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjlytle/565773 to your computer and use it in GitHub Desktop.
Save tjlytle/565773 to your computer and use it in GitHub Desktop.
Calibre Recipe for Doctrine2 Manual
#!/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