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

  1. from calibre.web.feeds.news import BasicNewsRecipe
  2.  
  3. class FIELDSTREAM(BasicNewsRecipe):
  4.     title      = 'Field and Stream'
  5.     __author__ = 'Starson17 and Tonythebookworm'
  6.     description = 'Hunting and Fishing and Gun Talk'
  7.     language = 'en'
  8.     no_stylesheets = True
  9.     publisher           = 'Starson17 and Tonythebookworm'
  10.     category            = 'food recipes, hunting, fishing, guns'
  11.     use_embedded_content= False
  12.     no_stylesheets      = True
  13.     oldest_article      = 24
  14.     remove_javascript   = True
  15.     remove_empty_feeds  = True
  16.     masthead_url        = 'http://www.fieldandstream.com/sites/all/themes/fs/logo.png'
  17.     cover_url           = 'http://www.arrowheadflyangler.com/Portals/1/Articles/FieldStream/Field%20and%20Stream%20March%20Fishing%20Edition%20Article%20Cover.jpg'
  18.     # recursions          = 0
  19.     max_articles_per_feed = 10
  20.     INDEX = 'http://www.fieldandstream.com'
  21.  
  22.     keep_only_tags     = [dict(name='div', attrs={'class':['interior-main']})
  23.                           ]
  24.     remove_tags = [dict(name='div', attrs={'id':['comments']})]
  25.  
  26.     def parse_index(self):
  27.         feeds = []
  28.         for title, url in [
  29.                             (u"Wild Chef", u"http://www.fieldandstream.com/blogs/wild-chef"),
  30.                             (u"The Gun Nut", u"http://www.fieldandstream.com/blogs/gun-nut"),
  31.                             (u"Whitetail 365", u"http://www.fieldandstream.com/blogs/whitetail-365"),
  32.                             (u"Fly Talk",  u"http://www.fieldandstream.com/blogs/flytalk"),
  33.                             (u"Generation Wild",  u"http://www.fieldandstream.com/blogs/generation-wild"),
  34.                             (u"Conservationist",  u"http://www.fieldandstream.com/blogs/conservationist"),
  35.                             (u"Honest Angler",  u"http://www.fieldandstream.com/blogs/honest-angler"),
  36.                             (u"Mans Best Friend", u"http://www.fieldandstream.com/blogs/mans-best-friend"),
  37.  
  38.                              ]:
  39.             articles = self.make_links(url)
  40.             if articles:
  41.                 feeds.append((title, articles))
  42.         return feeds
  43.  
  44.     def make_links(self, url):
  45.         title = 'Temp'
  46.         current_articles = []
  47.         soup = self.index_to_soup(url)
  48.         print 'The soup is: ', soup
  49.         for item in soup.findAll('h2'):
  50.             print 'item is: ', item
  51.             link = item.find('a')
  52.             print 'the link is: ', link
  53.             if link:
  54.                 url         = self.INDEX + link['href']
  55.                 title       = self.tag_to_string(link)
  56.                 print 'the title is: ', title
  57.                 print 'the url is: ', url
  58.                 print 'the title is: ', title
  59.                 current_articles.append({'title': title, 'url': url, 'description':'', 'date':''}) # append all this
  60.         return current_articles
  61.  
  62.  
  63.  
  64.  
  65.