home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_3904 < prev    next >
Encoding:
Text File  |  2009-10-14  |  3.7 KB  |  83 lines

  1.  
  2. __license__   = 'GPL v3'
  3. __copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
  4. '''
  5. miamiherald.com
  6. '''
  7.  
  8. from calibre.web.feeds.news import BasicNewsRecipe
  9.  
  10. class TheMiamiHerald(BasicNewsRecipe):
  11.     title                 = 'The Miami Herald'
  12.     __author__            = 'Darko Miletic and Sujata Raman'
  13.     description           = "Miami-Dade and Broward's source for the latest breaking local news on sports, weather, business, jobs, real estate, shopping, health, travel, entertainment, & more."
  14.     oldest_article        = 1
  15.     max_articles_per_feed = 100
  16.     publisher             = u'The Miami Herald'
  17.     category              = u'miami herald, weather, dolphins, news, miami news, local news, miamiherald, miami newspaper, miamiherald.com, miami, the miami herald, broward, miami-dade'
  18.     language = 'en'
  19.  
  20.     no_stylesheets        = True
  21.     use_embedded_content  = False
  22.     encoding              = 'cp1252'
  23.     remove_javascript     = True
  24.  
  25.     extra_css = '''
  26.                 h1{font-family:Arial,Helvetica,sans-serif; font-size:large; color:#1A272F; }
  27.                 .subheadline{font-family:Arial,Helvetica,sans-serif; font-size:30%; color: #666666;}
  28.                 #storyBodyContent{font-family:Arial,Helvetica,sans-serif; font-size:xx-small; }
  29.                 .byline{font-family:Arial,Helvetica,sans-serif; font-size:30%; color:#58595B; }
  30.                 .credit_line{font-family:Arial,Helvetica,sans-serif; font-size:30%; color:#58595B; }
  31.                 .storyPublishDate{font-family:Arial,Helvetica,sans-serif; font-size:30%; color:#666666; }
  32.                 .shirttail{font-family:Arial,Helvetica,sans-serif; font-size:30%; color:#666666;font-style:italic }
  33.                 .imageCaption{font-family:Arial,Helvetica,sans-serif; font-size:30%; color:#666666; }
  34.                 '''
  35.  
  36.     keep_only_tags = [dict(name='div', attrs={'id':['storyBody','storyPhotoContentArea']}),
  37.                       ]
  38.  
  39.     remove_tags = [dict(name=['object','link','embed']),
  40.                    dict(name='div', attrs={'class':["imageBuyButton","shareLinksArea","storyTools","spill_navigation pagination","circPromoArea","storyTools_footer","storyYahooContentMatch"]}) ,
  41.                    dict(name='div', attrs={'id':["pluck","mlt","storyAssets"]}) ]
  42.  
  43.  
  44.     feeds = [
  45.              (u'Breaking News'  , u'http://www.miamiherald.com/416/index.xml' )
  46.              ,(u'Miami-Dade' , u'http://www.miamiherald.com/460/index.xml' )
  47.              ,(u'Broward' , u'http://www.miamiherald.com/467/index.xml' )
  48.              ,(u'Florida Keys' , u'http://www.miamiherald.com/505/index.xml' )
  49.              ,(u'Florida' , u'http://www.miamiherald.com/569/index.xml' )
  50.              ,(u'Nation' , u'http://www.miamiherald.com/509/index.xml' )
  51.              ,(u'World' , u'http://www.miamiherald.com/578/index.xml' )
  52.              ,(u'Americas' , u'http://www.miamiherald.com/579/index.xml' )
  53.              ,(u'Cuba' , u'http://www.miamiherald.com/581/index.xml' )
  54.              ,(u'Haiti' , u'http://www.miamiherald.com/582/index.xml' )
  55.              ,(u'Politics' , u'http://www.miamiherald.com/515/index.xml' )
  56.              ,(u'Education' , u'http://www.miamiherald.com/295/index.xml' )
  57.              ,(u'Environment' , u'http://www.miamiherald.com/573/index.xml' )
  58.             ]
  59.  
  60.  
  61.  
  62.  
  63.  
  64.     def get_article_url(self, article):
  65.         ans = article.get('guid', None)
  66.         print ans
  67.         try:
  68.             self.log('Looking for full story link in', ans)
  69.             soup = self.index_to_soup(ans)
  70.             x = soup.find(text="Full Story")
  71.  
  72.             if x is not None:
  73.                 a = x.parent
  74.                 if a and a.has_key('href'):
  75.                     ans = 'http://www.miamiherald.com'+a['href']
  76.                     self.log('Found full story link', ans)
  77.         except:
  78.             pass
  79.         return ans
  80.  
  81.  
  82.  
  83.