View Single Post
Old 12-22-2010, 08:43 PM   #1
daviestown
Member
daviestown began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Dec 2010
Device: Sony Reader PRS-650
Adding a Table of Contents for PRS-650

Hi, I'm downloading Financial Times articles and would like to have a "Table of Contents" created for the eBook... using the each feed's title as the separate sections.

Here is the code... can you help guide me on how to add this feature?

Thank you so much!

Davies Town


Code:

Spoiler:

class AdvancedUserRecipe1293009575(BasicNewsRecipe):
title = 'Financial Times'
description = 'Financial Times'
publisher = 'Financial Times'
oldest_article = 2
max_articles_per_feed = 100
no_stylesheets = True
use_embedded_content = False
needs_subscription = True
simultaneous_downloads= 5
delay = 0
LOGIN = 'https://registration.ft.com/registration/barrier/login'


def get_browser(self):
br = BasicNewsRecipe.get_browser()
if self.username is not None and self.password is not None:
br.open(self.LOGIN)
br.select_form(name='loginForm')
br['username'] = self.username
br['password'] = self.password
br.submit()
return br

keep_only_tags = [ dict(name='div', attrs={'id':'cont'}) ]
remove_tags_after = dict(name='p', attrs={'class':'copyright'})
remove_tags = [ dict(name='div', attrs={'id':'floating-con'}) ]
remove_tags = [ dict(name='p', attrs={'class':'copyright'}) ]

feeds = [(u'World', u'http://www.ft.com/rss/world')
,(u'US', u'http://www.ft.com/rss/world/us')
,(u'Canada', u'http://www.ft.com/rss/world/canada')
,(u'Asia-Pacific', u'http://www.ft.com/rss/world/asiapacific')
,(u'Equities', u'http://www.ft.com/rss/markets/equities')
,(u'Commodities', u'http://www.ft.com/rss/markets/commodities')
]

def preprocess_html(self, soup):
content_type = soup.find('meta', {'http-equiv':'Content-Type'})
if content_type:
content_type['content'] = 'text/html; charset=utf-8'
return soup


daviestown is offline   Reply With Quote