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

  1. import re
  2.  
  3. from calibre.web.feeds.news import BasicNewsRecipe
  4. import mechanize
  5.  
  6. class AdvancedUserRecipe1283848012(BasicNewsRecipe):
  7.     description   = 'This is a recipe of Ynet.co.il. The recipe opens the article page and clicks on an advertisement to not hurt the sites advertising income.'
  8.     cover_url      = 'http://www.bneiakiva.net/uploads/images/ynet%282%29.jpg'
  9.     title          = u'Ynet'
  10.     __author__ = 'marbs'
  11.     language              = 'he'
  12.     extra_css='img {max-width:100%;direction: rtl;} #article{direction: rtl;} div{direction: rtl;} title{direction: rtl; } article_description{direction: rtl; } a.article{direction: rtl; } calibre_feed_description{direction: rtl; } body{direction: ltr;}'
  13.     remove_attributes = ['width']
  14.     simultaneous_downloads = 5
  15.     keep_only_tags =dict(name='div', attrs={'id':'articleContainer'})
  16.     remove_javascript     = True
  17.     timefmt        = '[%a, %d %b, %Y]'
  18.     oldest_article = 1
  19.     remove_tags = [dict(name='p', attrs={'text':[' ']})]
  20.     max_articles_per_feed = 100
  21.     preprocess_regexps = [
  22.         (re.compile(r'<p> </p>', re.DOTALL|re.IGNORECASE), lambda match: '')
  23.         ]
  24.  
  25.     def preprocess_html(self, soup):
  26.         soup.html['dir'] = 'rtl'
  27.         soup.body['dir'] = 'rtl'
  28.         return soup
  29.  
  30.     feeds =[(u'\u05d7\u05d3\u05e9\u05d5\u05ea',
  31.   u'http://www.ynet.co.il/Integration/StoryRss2.xml'),
  32.  (u'\u05db\u05dc\u05db\u05dc\u05d4',
  33.   u'http://www.ynet.co.il/Integration/StoryRss6.xml'),
  34.  (u'\u05e6\u05e8\u05db\u05e0\u05d5\u05ea',
  35.   u'http://www.ynet.co.il/Integration/StoryRss437.xml'),
  36.  (u'\u05e1\u05e4\u05d5\u05e8\u05d8',
  37.   u'http://www.ynet.co.il/Integration/StoryRss3.xml'),
  38.  (u'\u05ea\u05e8\u05d1\u05d5\u05ea',
  39.   u'http://www.ynet.co.il/Integration/StoryRss538.xml'),
  40.  (u'\u05de\u05e2\u05d5\u05e8\u05d1\u05d5\u05ea \u05d5\u05d7\u05d1\u05e8\u05d4',
  41.   u'http://www.ynet.co.il/Integration/StoryRss3262.xml'),
  42.  (u'\u05d1\u05e8\u05d9\u05d0\u05d5\u05ea',
  43.   u'http://www.ynet.co.il/Integration/StoryRss1208.xml'),
  44.  (u'\u05d9\u05e8\u05d5\u05e7',
  45.   u'http://www.ynet.co.il/Integration/StoryRss4872.xml'),
  46.  (u'\u05de\u05d7\u05e9\u05d1\u05d9\u05dd',
  47.   u'http://www.ynet.co.il/Integration/StoryRss544.xml'),
  48.  (u'\u05e8\u05db\u05d1', u'http://www.ynet.co.il/Integration/StoryRss550.xml'),
  49.  (u'\u05ea\u05d9\u05d9\u05e8\u05d5\u05ea',
  50.   u'http://www.ynet.co.il/Integration/StoryRss598.xml'),
  51.  (u'\u05d4\u05d5\u05e8\u05d9\u05dd',
  52.   u'http://www.ynet.co.il/Integration/StoryRss3052.xml'),
  53.  (u'\u05d0\u05d5\u05db\u05dc',
  54.   u'http://www.ynet.co.il/Integration/StoryRss975.xml'),
  55.  (u'\u05d9\u05d4\u05d3\u05d5\u05ea',
  56.   u'http://www.ynet.co.il/Integration/StoryRss4403.xml'),
  57.  (u'\u05de\u05d3\u05e2 \u05d5\u05d8\u05d1\u05e2',
  58.   u'http://www.ynet.co.il/Integration/StoryRss2142.xml'),
  59.  (u'\u05d9\u05d7\u05e1\u05d9\u05dd',
  60.   u'http://www.ynet.co.il/Integration/StoryRss3925.xml'),
  61.  (u'\u05d3\u05e2\u05d5\u05ea',
  62.   u'http://www.ynet.co.il/Integration/StoryRss194.xml')]
  63.  
  64.     def print_version(self, url):
  65. #remove from here
  66.         br = BasicNewsRecipe.get_browser()
  67.         br.open(url)
  68.         br.follow_link(mechanize.Link(base_url = '', url =url, text = '', tag = 'a', attrs = [{'id':'buzzerATop'}]))
  69. #to here to stop supporting ynet...
  70.         split1 = url.split("-")
  71.         print_url = 'http://www.ynet.co.il/Ext/Comp/ArticleLayout/CdaArticlePrintPreview/1,2506,L-' + split1[1]
  72.         return print_url
  73.