home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / Calibre / calibre-0.8.18.msi / file_280 / wired_daily.recipe < prev    next >
Text File  |  2011-09-09  |  2KB  |  60 lines

  1. #!/usr/bin/env  python
  2. __license__   = 'GPL v3'
  3. __docformat__ = 'restructuredtext en'
  4.  
  5. import re
  6.  
  7. from calibre.web.feeds.news import BasicNewsRecipe
  8. from calibre.ebooks.chardet import xml_to_unicode
  9.  
  10. class Wired_Daily(BasicNewsRecipe):
  11.  
  12.     title = 'Wired Daily Edition'
  13.     __author__ = 'Kovid Goyal'
  14.     description = 'Technology news'
  15.     timefmt  = ' [%Y%b%d  %H%M]'
  16.     language = 'en'
  17.  
  18.     no_stylesheets = True
  19.  
  20.     preprocess_regexps = [(re.compile(r'<head.*</head>', re.DOTALL), lambda m:
  21.         '<head></head>')]
  22.  
  23.     remove_tags_before = dict(name='div', id='content')
  24.     remove_tags = [dict(id=['header', 'commenting_module', 'post_nav',
  25.         'social_tools', 'sidebar', 'footer', 'social_wishlist', 'pgwidget',
  26.         'outerWrapper', 'inf_widget']),
  27.         {'class':['entryActions', 'advertisement', 'entryTags']},
  28.         dict(name=['noscript', 'script']),
  29.         dict(name='h4', attrs={'class':re.compile(r'rat\d+')}),
  30.         {'class':lambda x: x and x.startswith('contentjump')},
  31.         dict(name='li', attrs={'class':['entryCategories', 'entryEdit']})]
  32.  
  33.  
  34.     feeds = [
  35.         ('Top News', 'http://feeds.wired.com/wired/index'),
  36.         ('Product Reviews',
  37.             'http://www.wired.com/reviews/feeds/latestProductsRss'),
  38.         ('Autopia', 'http://www.wired.com/autopia/feed/'),
  39.         ('Danger Room', 'http://www.wired.com/dangerroom/feed/'),
  40.         ('Epicenter', 'http://www.wired.com/epicenter/feed/'),
  41.         ('Gadget Lab', 'http://www.wired.com/gadgetlab/feed/'),
  42.         ('Geek Dad', 'http://www.wired.com/geekdad/feed/'),
  43.         ('Playbook', 'http://www.wired.com/playbook/feed/'),
  44.         ('Rawfile', 'http://www.wired.com/rawfile/feed/'),
  45.         ('This Day in Tech', 'http://www.wired.com/thisdayintech/feed/'),
  46.         ('Threat Level', 'http://www.wired.com/threatlevel/feed/'),
  47.         ('Underwire', 'http://www.wired.com/underwire/feed/'),
  48.         ('Web Monkey', 'http://www.webmonkey.com/feed/'),
  49.         ('Science', 'http://www.wired.com/wiredscience/feed/'),
  50.         ]
  51.  
  52.     def populate_article_metadata(self, article, soup, first):
  53.         if article.text_summary:
  54.             article.text_summary = xml_to_unicode(article.text_summary,
  55.                     resolve_entities=True)[0]
  56.  
  57.     def print_version(self, url):
  58.         return url + '/all/1'
  59.  
  60.