home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_4046 < prev    next >
Encoding:
Text File  |  2009-11-13  |  3.4 KB  |  95 lines

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2008-2009, Darko Miletic <darko.miletic at gmail.com>'
  5. '''
  6. spiegel.de
  7. '''
  8.  
  9. from calibre.web.feeds.news import BasicNewsRecipe
  10.  
  11.  
  12. class Spiegel_int(BasicNewsRecipe):
  13.     title                 = 'Spiegel Online International'
  14.     __author__            = 'Darko Miletic and Sujata Raman'
  15.     description           = "News and POV from Europe's largest newsmagazine"
  16.     oldest_article        = 7
  17.     max_articles_per_feed = 100
  18.     language = 'en'
  19.  
  20.     no_stylesheets        = True
  21.     use_embedded_content  = False
  22.     publisher             = 'SPIEGEL ONLINE GmbH'
  23.     category              = 'news, politics, Germany'
  24.     lang                  = 'en'
  25.     recursions = 1
  26.     match_regexps = [r'http://www.spiegel.de/.*-[1-9],00.html']
  27.     conversion_options = {
  28.                              'comments'    : description
  29.                             ,'tags'        : category
  30.                             ,'language'    : lang
  31.                             ,'publisher'   : publisher
  32.                             ,'pretty_print': True
  33.                          }
  34.  
  35.     extra_css = '''
  36.                    #spArticleColumn{font-family:verdana,arial,helvetica,geneva,sans-serif ; }
  37.                    h1{color:#666666; font-weight:bold;}
  38.                    h2{color:#990000;}
  39.                    h3{color:#990000;}
  40.                    h4 {color:#990000;}
  41.                    a{color:#990000;}
  42.                    .spAuthor{font-style:italic;}
  43.                    #spIntroTeaser{font-weight:bold;}
  44.                    .spCredit{color:#666666; font-size:x-small;}
  45.                    .spShortDate{font-size:x-small;}
  46.                    .spArticleImageBox {font-size:x-small;}
  47.                    .spPhotoGallery{font-size:x-small; color:#990000 ;}
  48.                 '''
  49.  
  50.     keep_only_tags = [
  51.                         dict(name ='div', attrs={'id': ['spArticleImageBox spAssetAlignleft','spArticleColumn']}),
  52.                     ]
  53.  
  54.     remove_tags = [
  55.                     dict(name='div', attrs={'id':['spSocialBookmark','spArticleFunctions','spMultiPagerHeadlines',]}),
  56.                     dict(name='div', attrs={'class':['spCommercial spM520','spArticleCredit','spPicZoom']}),
  57.                     ]
  58.  
  59.     feeds          = [(u'Spiegel Online', u'http://www.spiegel.de/schlagzeilen/rss/0,5291,676,00.xml')]
  60.  
  61.     def postprocess_html(self, soup,first):
  62.  
  63.          for tag in soup.findAll(name='div',attrs={'id':"spMultiPagerControl"}):
  64.                 tag.extract()
  65.  
  66.          p =  soup.find(name = 'p', attrs={'id':'spIntroTeaser'})
  67.  
  68.          if p.string is not None:
  69.             t = p.string.rpartition(':')[0]
  70.  
  71.             if 'Part'in t:
  72.                 if soup.h1 is not None:
  73.                      soup.h1.extract()
  74.                 if soup.h2 is not None:
  75.                  soup.h2.extract()
  76.                  functag = soup.find(name= 'div', attrs={'id':"spArticleFunctions"})
  77.                  if functag is not None:
  78.                      functag.extract()
  79.                  auttag = soup.find(name= 'p', attrs={'class':"spAuthor"})
  80.                  if auttag is not None:
  81.                      auttag.extract()
  82.  
  83.                  pictag = soup.find(name= 'div', attrs={'id':"spArticleTopAsset"})
  84.                  if pictag is not None:
  85.                      pictag.extract()
  86.  
  87.  
  88.          return soup
  89.  
  90.    # def print_version(self, url):
  91.    #     main, sep, rest = url.rpartition(',')
  92.    #     rmain, rsep, rrest = main.rpartition(',')
  93.    #     return rmain + ',druck-' + rrest + ',' + rest
  94.  
  95.