Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Recipes

Notices

Reply
 
Thread Tools Search this Thread
Old 05-18-2011, 04:39 PM   #1
schuster
Zealot
schuster doesn't litterschuster doesn't litter
 
Posts: 116
Karma: 100
Join Date: Jan 2011
Location: Germany / NRW /Köln
Device: prs-650 / prs-350 /kindle 3
recipe for Capital.de - german

Code:
from calibre.web.feeds.news import BasicNewsRecipe
class AdvancedUserRecipe1305470859(BasicNewsRecipe):
    title                 = u'Capital.de'
    language              = 'de'
    __author__            = 'schuster'
    oldest_article        =7
    max_articles_per_feed = 35
    no_stylesheets        = True
    remove_javascript     = True
    use_embedded_content  = False
    masthead_url = 'http://www.wirtschaftsmedien-shop.de/media/stores/wirtschaftsmedien/capital/teaser_large_abo.jpg'
    cover_url = 'http://d1kb9jvg6ylufe.cloudfront.net/WebsiteCMS/de/unternehmen/linktipps/mainColumn/08/image/DE_Capital_bis20mm_SW.jpg'

    def preprocess_html(self, soup):
        for alink in soup.findAll('a'):
            if alink.string is not None:
               tstr = alink.string
               alink.replaceWith(tstr)
        return soup                      

    extra_css = '''
                    h1{font-family:Arial,Helvetica,sans-serif; font-weight:bold;font-size:large;}
                    h4{font-family:Arial,Helvetica,sans-serif; font-weight:normal;font-size:small;}
                    img {min-width:300px; max-width:600px; min-height:300px; max-height:800px}
                    p{font-family:Arial,Helvetica,sans-serif;font-size:small;}
                    body{font-family:Helvetica,Arial,sans-serif;font-size:small;}
	'''
    def print_version(self, url):
        return url.replace ('nv=rss#utm_source=rss2&utm_medium=rss_feed&utm_campaign=/', 'mode=print')
    remove_tags_bevor = [dict(name='td', attrs={'class':'textcell'})]
    remove_tags_after = [dict(name='div', attrs={'class':'artikelsplit'})]

    feeds = [   (u'Wirtschaftsmagazin', u'http://www.capital.de/rss/'),
	(u'Unternehmen', u'http://www.capital.de/rss/unternehmen'),
	(u'Finanz & Geldanlage', u'http://www.capital.de/rss/finanzen/geldanlage')]

    def append_page(self, soup, appendtag, position):
        pager = soup.find('div',attrs={'class':'artikelsplit'})
        if pager:
           nexturl = self.INDEX + pager.a['href']
           soup2 = self.index_to_soup(nexturl)
           texttag = soup2.find('div', attrs={'class':'printable'})
           for it in texttag.findAll(style=True):
               del it['style']
           newpos = len(texttag.contents)
           self.append_page(soup2,texttag,newpos)
           texttag.extract()
           appendtag.insert(position,texttag)


    def preprocess_html(self, soup):
        for item in soup.findAll(style=True):
            del item['style']
        for item in soup.findAll('div', attrs={'class':'artikelsplit'}):
            item.extract()
        self.append_page(soup, soup.body, 3)
        pager = soup.find('div',attrs={'class':'artikelsplit'})
        if pager:
           pager.extract()
        return self.adeify_images(soup)



    remove_tags = [dict(attrs={'class':['navSeitenAlle', 'kommentieren', 'teaserheader', 'teasercontent', 'info', 'zwischenhead', 'artikelsplit']}),
                dict(id=['topNav', 'mainNav', 'subNav', 'socialmedia', 'footerRahmen', 'gatrixx_marktinformationen', 'pager', 'weitere']),
                dict(span=['ratingtext', 'Gesamtranking', 'h3','']),
	dict(rel=['canonical'])]

Last edited by schuster; 05-18-2011 at 04:48 PM.
schuster is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
recipe for Express.de - german schuster Recipes 1 06-05-2011 10:58 AM
recipe for Bild.de - German schuster Recipes 1 06-03-2011 07:56 AM
recipe for Golem.de - German schuster Recipes 3 05-15-2011 12:33 PM
recipe for Astronomie heute - german schuster Recipes 0 05-14-2011 01:42 PM
Hi from the ex capital of culture snickp Introduce Yourself 14 01-30-2009 03:27 PM


All times are GMT -4. The time now is 08:51 AM.


MobileRead.com is a privately owned, operated and funded community.