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

  1. from calibre.web.feeds.news import BasicNewsRecipe
  2.  
  3. class AdvancedUserRecipe1289990851(BasicNewsRecipe):
  4.     title          = u'TSN'
  5.     oldest_article = 7
  6.     max_articles_per_feed = 50
  7.     language = 'en_CA'
  8.     __author__ = 'Nexus'
  9.     no_stylesheets = True
  10.     INDEX = 'http://tsn.ca/nhl/story/?id=nhl'
  11.     keep_only_tags = [dict(name='div', attrs={'id':['tsnColWrap']}),
  12.                              dict(name='div', attrs={'id':['tsnStory']})]
  13.     remove_tags = [dict(name='div', attrs={'id':'tsnRelated'}),
  14.                           dict(name='div', attrs={'class':'textSize'})]
  15.  
  16.     def parse_index(self):
  17.         feeds = []
  18.         soup = self.index_to_soup(self.INDEX)
  19.         feed_parts = soup.findAll('div', attrs={'class': 'feature'})
  20.         for feed_part  in feed_parts:
  21.             articles = []
  22.             if not feed_part.h2:
  23.                 continue
  24.             feed_title = feed_part.h2.string
  25.             article_parts = feed_part.findAll('a')
  26.             for article_part in article_parts:
  27.                 article_title = article_part.string
  28.                 article_date = ''
  29.                 article_url = 'http://tsn.ca/' + article_part['href']
  30.                 articles.append({'title': article_title, 'url': article_url, 'description':'', 'date':article_date})
  31.             if articles:
  32.                 feeds.append((feed_title, articles))
  33.         return feeds
  34.  
  35.