home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_4142 < prev    next >
Encoding:
Text File  |  2010-02-17  |  2.8 KB  |  75 lines

  1.  
  2. __license__   = 'GPL v3'
  3. __copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
  4. '''
  5. www.wired.co.uk
  6. '''
  7.  
  8. from calibre import strftime
  9. from calibre.web.feeds.news import BasicNewsRecipe
  10.  
  11. class Wired_UK(BasicNewsRecipe):
  12.     title                 = 'Wired Magazine - UK edition'
  13.     __author__            = 'Darko Miletic'
  14.     description           = 'Gaming news'
  15.     publisher             = 'Conde Nast Digital'
  16.     category              = 'news, games, IT, gadgets'
  17.     oldest_article        = 32
  18.     max_articles_per_feed = 100
  19.     no_stylesheets        = True
  20.     encoding              = 'utf-8'
  21.     use_embedded_content  = False
  22.     masthead_url          = 'http://www.wired.co.uk/_/media/wired-logo_UK.gif'
  23.     language              = 'en_GB'
  24.     extra_css             = ' body{font-family: Palatino,"Palatino Linotype","Times New Roman",Times,serif} img{margin-bottom: 0.8em } .img-descr{font-family: Tahoma,Arial,Helvetica,sans-serif; font-size: 0.6875em; display: block} '
  25.     index                 = 'http://www.wired.co.uk/wired-magazine.aspx'
  26.  
  27.     conversion_options = {
  28.                           'comment'   : description
  29.                         , 'tags'      : category
  30.                         , 'publisher' : publisher
  31.                         , 'language'  : language
  32.                         }
  33.  
  34.     keep_only_tags = [dict(name='div', attrs={'class':'article-box'})]
  35.     remove_tags = [
  36.                      dict(name=['object','embed','iframe','link'])
  37.                     ,dict(attrs={'class':['opts','comment','stories']})
  38.                   ]
  39.     remove_tags_after = dict(name='div',attrs={'class':'stories'})
  40.     remove_attributes = ['height','width']
  41.  
  42.  
  43.     def parse_index(self):
  44.         totalfeeds = []
  45.         soup   = self.index_to_soup(self.index)
  46.         maincontent = soup.find('div',attrs={'class':'main-content'})
  47.         mfeed = []
  48.         if maincontent:
  49.            st = maincontent.find(attrs={'class':'most-wired-box'})
  50.            if st:
  51.               for itt in st.findAll('a',href=True):
  52.                url   = 'http://www.wired.co.uk' + itt['href']
  53.                title = self.tag_to_string(itt)
  54.                description = ''
  55.                date  = strftime(self.timefmt)
  56.                mfeed.append({
  57.                                   'title'      :title
  58.                                  ,'date'       :date
  59.                                  ,'url'        :url
  60.                                  ,'description':description
  61.                                 })
  62.         totalfeeds.append(('Articles', mfeed))
  63.         return totalfeeds
  64.  
  65.     def get_cover_url(self):
  66.         cover_url = None
  67.         soup = self.index_to_soup(self.index)
  68.         cover_item = soup.find('span', attrs={'class':'cover'})
  69.         if cover_item:
  70.            cover_url = cover_item.img['src']
  71.         return cover_url
  72.  
  73.     def print_version(self, url):
  74.         return url + '?page=all'
  75.