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

  1. from calibre.web.feeds.recipes import BasicNewsRecipe
  2.  
  3. class Gry_online_pl(BasicNewsRecipe):
  4.     title          = u'Gry-Online.pl'
  5.     __author__        = 'fenuks'
  6.     description   = 'Gry-Online.pl - computer games'
  7.     category       = 'games'
  8.     language       = 'pl'
  9.     oldest_article = 13
  10.     INDEX= 'http://www.gry-online.pl/'
  11.     cover_url='http://www.gry-online.pl/img/1st_10/1st-gol-logo.png'
  12.     max_articles_per_feed = 100
  13.     no_stylesheets= True
  14.     extra_css              = 'p.wn1{font-size:22px;}'
  15.     remove_tags_after= [dict(name='div', attrs={'class':['tresc-newsa']})]
  16.     keep_only_tags = [dict(name='div', attrs={'class':['txthead']}), dict(name='p', attrs={'class':['wtx1', 'wn1', 'wob']}), dict(name='a', attrs={'class':['num_str_nex']})]
  17.     #remove_tags= [dict(name='div', attrs={'class':['news_plat']})]
  18.     feeds          = [(u'Newsy', 'http://www.gry-online.pl/rss/news.xml'), ('Teksty', u'http://www.gry-online.pl/rss/teksty.xml')]
  19.  
  20.  
  21.     def append_page(self, soup, appendtag):
  22.         nexturl = soup.find('a', attrs={'class':'num_str_nex'})
  23.         if appendtag.find('a', attrs={'class':'num_str_nex'}) is not None:
  24.             appendtag.find('a', attrs={'class':'num_str_nex'}).replaceWith('\n')
  25.         if nexturl is not None:
  26.             if 'strona' in nexturl.div.string:
  27.                 nexturl= self.INDEX + nexturl['href']
  28.                 soup2 = self.index_to_soup(nexturl)
  29.                 pagetext = soup2.findAll(name='p', attrs={'class':['wtx1', 'wn1', 'wob']})
  30.                 for tag in pagetext:
  31.                     pos = len(appendtag.contents)
  32.                     appendtag.insert(pos, tag)
  33.                 self.append_page(soup2, appendtag)
  34.  
  35.  
  36.     def preprocess_html(self, soup):
  37.          self.append_page(soup, soup.body)
  38.          return soup
  39.