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

  1. from calibre.web.feeds.news import BasicNewsRecipe
  2. import re
  3.  
  4. class TheSkepticalInquirer(BasicNewsRecipe):
  5.     title          = u'The Skeptical Inquirer'
  6.     description    = 'Investigation of fringe science and paranormal claims.'
  7.     language       = 'en'
  8.     __author__     = 'Starson17'
  9.     oldest_article = 31
  10.     cover_url           = 'http://www.skeptricks.com/images/Skeptical_Inquirer_Magazine.jpg'
  11.     remove_empty_feeds    = True
  12.     remove_javascript   = True
  13.     max_articles_per_feed = 50
  14.     no_stylesheets = True
  15.  
  16.     keep_only_tags = [dict(name='div', attrs={'id':['content', 'bio']})]
  17.  
  18.     remove_tags = [
  19.                   dict(name='div', attrs={'id':['socialMedia']}),
  20.                   ]
  21.  
  22.     preprocess_regexps = [
  23.         (re.compile(r'\.\(JavaScript must be enabled to view this email address\)', re.DOTALL|re.IGNORECASE), lambda match: ''),
  24.         ]
  25.  
  26.     def parse_index(self):
  27.         feeds = []
  28.         for title, url in [("The Skeptical Inquirer", "http://www.csicop.org")]:
  29.             articles = self.make_links(url)
  30.             if articles:
  31.                 feeds.append((title, articles))
  32.         return feeds
  33.  
  34.     def make_links(self, url):
  35.         soup = self.index_to_soup(url)
  36.         title = ''
  37.         current_articles = []
  38.         for item in soup.findAll(attrs={'class':['article-single bigger']}):
  39.             page_url = url + str(item.a["href"])
  40.             title = str(item.a.string)
  41.             current_articles.append({'title': title, 'url': page_url, 'description':'', 'date':''})
  42.         return current_articles
  43.  
  44.     extra_css = '''
  45.                     h1{font-family:Arial,Helvetica,sans-serif; font-weight:bold;font-size:large;}
  46.                     h2{font-family:Arial,Helvetica,sans-serif; font-weight:normal;font-size:small;}
  47.                     p{font-family:Arial,Helvetica,sans-serif;font-size:small;}
  48.                     body{font-family:Helvetica,Arial,sans-serif;font-size:small;}
  49.         '''
  50.  
  51.