View Single Post
Old 02-25-2011, 05:21 PM   #3
Finbar127
Member
Finbar127 began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Feb 2011
Device: Kindle 3
Thanks. I tried adjusting that code to fit my recipe and I ended up with this:

Spoiler:
Code:
class AdvancedUserRecipe1297969350(BasicNewsRecipe):
    title = u'Mahopac News'
    oldest_article = 6
    max_articles_per_feed = 100
    no_stylesheets = True
    remove_attributes=['style'] 
    remove_javascript = True
    conversion_options = {'linearize_tables' : True}
    remove_tags = [dict(name='span', attrs={'class':'lp'})]
    extra_css = '.title {font-size: x-large; font-weight: bold}'

    feeds = [(u'Headlines', u'http://www.mahopacnews.com/rssheadlines.xml')]

    def parse_feeds (self):
          feeds = BasicNewsRecipe.parse_feeds(self)
          opinionArticles = []
          for curfeed in feeds:
                delList = []
                for a,curarticle in enumerate(curfeed.articles):
                      if curarticle.title.upper().find('OPINION:') >= 0:
                            opinionArticles.append(curarticle)
                            delList.append(curarticle)
                if len(delList)>0:
                      for d in delList:
                            index = curfeed.articles.index(d)
                            curfeed.articles[index:index+1] = []

          if len(opinionArticles) > 0:
                pfeed = Feed()
                pfeed.title = 'Opinion'
                pfeed.descrition = 'Opinion Feed (Virtual)'
                pfeed.image_url  = None
                pfeed.oldest_article = 30
                pfeed.id_counter = len(recipeArticles)
                pfeed.articles = opinionArticles[:]
                feeds.append(pfeed)

          return feeds

    def print_version(self,url):

          baseURL='http://www.mahopacnews.com/LPprintwindow.LASSO?-token.editorialcall='
          segments = url.split('-')
          printURL = baseURL + segments[5]
        
          return printURL


I get the following error:

line 32, in parse_feeds
pfeed = Feed()
NameError: global name 'Feed' is not defined

Do you know where I would define Feed in the recipe? Also Could you point me to a recipe where this particular chunk of code is used?

Last edited by Finbar127; 02-25-2011 at 05:28 PM.
Finbar127 is offline   Reply With Quote