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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
  3.  
  4. '''
  5. sarajevo-x.com
  6. '''
  7.  
  8. import re
  9. from calibre.web.feeds.recipes import BasicNewsRecipe
  10. from calibre.ebooks.BeautifulSoup import Tag, NavigableString
  11.  
  12. class SarajevoX(BasicNewsRecipe):
  13.     title                 = 'Sarajevo-x.com'
  14.     __author__            = 'Darko Miletic'
  15.     description           = 'Sarajevo-x.com - najposjeceniji bosanskohercegovacki internet portal'
  16.     publisher             = 'InterSoft d.o.o.'
  17.     category              = 'news, politics, Bosnia and Herzegovina,Sarajevo-x.com, internet, portal, vijesti, bosna i hercegovina, sarajevo'
  18.     oldest_article        = 2
  19.     delay                 = 1
  20.     max_articles_per_feed = 100
  21.     no_stylesheets        = True
  22.     encoding              = 'cp1250'
  23.     use_embedded_content  = False
  24.     language              = 'bs'
  25.     extra_css = ' @font-face {font-family: "sans1";src:url(res:///opt/sony/ebook/FONT/tt0003m_.ttf)} body{font-family: Arial,Verdana,Helvetica,sans1,sans-serif} .article_description{font-family: sans1, sans-serif} div#fotka{display: block} img{margin-bottom: 0.5em} '
  26.  
  27.     conversion_options = {
  28.                           'comment'          : description
  29.                         , 'tags'             : category
  30.                         , 'publisher'        : publisher
  31.                         , 'language'         : language
  32.                         }
  33.  
  34.     preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')]
  35.  
  36.     keep_only_tags    = [dict(name='div', attrs={'class':'content-bg'})]
  37.     remove_tags_after = dict(name='div',attrs={'class':'izvor'})
  38.     remove_tags       = [dict(name=['object','link','base','table'])]
  39.     remove_attributes = ['height','width','alt','border']
  40.  
  41.     feeds = [
  42.                (u'BIH'          , u'http://www.sarajevo-x.com/rss/bih'          )
  43.               ,(u'Svijet'       , u'http://www.sarajevo-x.com/rss/svijet'       )
  44.               ,(u'Biznis'       , u'http://www.sarajevo-x.com/rss/biznis'       )
  45.               ,(u'Sport'        , u'http://www.sarajevo-x.com/rss/sport'        )
  46.               ,(u'Showtime'     , u'http://www.sarajevo-x.com/rss/showtime'     )
  47.               ,(u'Scitech'      , u'http://www.sarajevo-x.com/rss/scitech'      )
  48.               ,(u'Lifestyle'    , u'http://www.sarajevo-x.com/rss/lifestyle'    )
  49.               ,(u'Kultura'      , u'http://www.sarajevo-x.com/rss/kultura'      )
  50.               ,(u'Zanimljivosti', u'http://www.sarajevo-x.com/rss/zanimljivosti')
  51.             ]
  52.  
  53.     def preprocess_html(self, soup):
  54.         dtag = soup.find('div',attrs={'id':'fotka'})
  55.         if dtag:
  56.            sp = soup.find('div',attrs={'id':'opisslike'})
  57.            img = soup.find('img')
  58.            if sp:
  59.                sp
  60.            else:
  61.                mtag  = Tag(soup,'div',[("id","opisslike"),("class","opscitech")])
  62.                mopis = NavigableString("Opis")
  63.                mtag.insert(0,mopis)
  64.                img.append(mtag)
  65.         return soup
  66.  
  67.