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

  1. import datetime
  2. from calibre.web.feeds.news import BasicNewsRecipe
  3.  
  4. class AdvancedUserRecipe1286242553(BasicNewsRecipe):
  5.     title          = u'CACM'
  6.     oldest_article = 7
  7.     max_articles_per_feed = 100
  8.     needs_subscription = True
  9.     feeds          = [(u'CACM', u'http://cacm.acm.org/magazine.rss')]
  10.     language = 'en'
  11.     __author__ = 'jonmisurda'
  12.     no_stylesheets        = True
  13.     remove_tags = [
  14.         dict(name='div', attrs={'class':['FeatureBox', 'ArticleComments', 'SideColumn', \
  15.               'LeftColumn', 'RightColumn', 'SiteSearch', 'MainNavBar','more', 'SubMenu', 'inner']})
  16.     ]
  17.     cover_url_pattern = 'http://cacm.acm.org/magazines/%d/%d'
  18.  
  19.     def get_browser(self):
  20.         br = BasicNewsRecipe.get_browser()
  21.         if self.username is not None and self.password is not None:
  22.             br.open('https://cacm.acm.org/login')
  23.             br.select_form(nr=1)
  24.             br['current_member[user]']   = self.username
  25.             br['current_member[passwd]'] = self.password
  26.             br.submit()
  27.         return br
  28.  
  29.     def get_cover_url(self):
  30.         now = datetime.datetime.now()
  31.  
  32.         cover_url = None
  33.         soup = self.index_to_soup(self.cover_url_pattern % (now.year, now.month))
  34.         cover_item = soup.find('img',attrs={'alt':'magazine cover image'})
  35.         if cover_item:
  36.            cover_url = cover_item['src']
  37.         return cover_url
  38.