home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_3670 < prev    next >
Encoding:
Text File  |  2010-03-15  |  2.9 KB  |  76 lines

  1. #!/usr/bin/env  python
  2. __license__   = 'GPL v3'
  3. __author__    = 'Lorenzo Vigentini, based on Darko Miletic'
  4. __copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>, Lorenzo Vigentini <l.vigentini at gmail.com>'
  5. __version__     = 'v1.02'
  6. __date__        = '14, March 2010'
  7. __description__ = 'Italian daily newspaper (english version)'
  8. # NOTE: the feeds url are broken on the main site as the permalink structure has been changed erroneously ie:
  9. # actual link in feed   http://www.corriere.it/english/10_marzo_11/legitimate_impediment_approved_de9ba480-2cfd-11df-a00c-00144f02aabe.shtml
  10. # this needs to be change to
  11. # real feed URL http://www.corriere.it/International/english/articoli/2010/03/11/legitimate_impediment_approved.shtml
  12. '''
  13. http://www.corriere.it/
  14. '''
  15.  
  16. from calibre.web.feeds.news import BasicNewsRecipe
  17.  
  18. class ilCorriereEn(BasicNewsRecipe):
  19.     author        = 'Lorenzo Vigentini, based on Darko Miletic'
  20.     description   = 'Italian daily newspaper (english version)'
  21.  
  22.     cover_url      = 'http://images.corriereobjects.it/images/static/common/logo_home.gif?v=200709121520'
  23.     title          = u'Il Corriere della sera (english) '
  24.     publisher      = 'RCS Digital'
  25.     category       = 'News, politics, culture, economy, general interest'
  26.  
  27.     language       = 'en'
  28.     timefmt        = '[%a, %d %b, %Y]'
  29.  
  30.     oldest_article = 5
  31.     max_articles_per_feed = 100
  32.     use_embedded_content  = False
  33.     recursion             = 10
  34.  
  35.     remove_javascript = True
  36.     no_stylesheets = True
  37.  
  38.     def get_article_url(self, article):
  39.         articleUrl= article.get('link')
  40.         segments = articleUrl.split('/')
  41.         basename = '/'.join(segments[:3]) + '/' + 'International/english/articoli/'
  42.  
  43.     #the date has to be redone with the url structure
  44.         mlist1 = ['gennaio','febbraio','marzo','aprile','maggio','giugno','luglio','agosto','settembre','ottobre','novembre','dicembre']
  45.         mlist2 = ['01','02','03','04','05','06','07','08','09','10','11','12']
  46.         myDate = segments[4].split('_')
  47.         x=0
  48.         for x in range(11):
  49.             if myDate[1] == mlist1[x]:
  50.                 noMonth=mlist2[x]
  51.                 break
  52.  
  53.         newDateUrl= '20'+ myDate[0] + '/' + noMonth + '/' + myDate[2] + '/'
  54.  
  55.     #clean the article title
  56.         articleURLseg=segments[5].split('-')
  57.         myArticle = (articleURLseg[0])[:-9] + '.shtml'
  58.  
  59.         myURL= basename + newDateUrl + myArticle
  60.         #print myURL
  61.         return myURL
  62.  
  63.     keep_only_tags = [dict(name='div', attrs={'class':['news-dettaglio article','article']})]
  64.  
  65.     remove_tags = [
  66.                    dict(name=['base','object','link','embed']),
  67.                    dict(name='div', attrs={'class':'news-goback'}),
  68.                    dict(name='ul', attrs={'class':'toolbar'})
  69.                   ]
  70.  
  71.     remove_tags_after = dict(name='p', attrs={'class':'footnotes'})
  72.  
  73.     feeds = [
  74.              (u'News'  , u'http://www.corriere.it/rss/english.xml'  )
  75.             ]
  76.