def collect(self, author, feed_url): feed = from_url(feed_url) for entry in feed.entries: cursor = conn.cursor() cursor.execute('select 1 from entries where url = ? limit 1', [unicode(entry.link)]) if not cursor.fetchall(): slug = '%s-%s' % (author, slugify(unicode(entry.title))) self.write(entry.link, entry.title, entry.description, entry.published, slug) cursor.execute('insert into entries values(?)', [unicode(entry.link)])
def check_feed_for_new_articles(self): """ Retrieves the list of new articles from the RSS feed """ log.info("Fetching %s article list...", self) feed = parser.from_url(self.feed_url) upstream_articles = [ UpstreamArticle(self, parse_token(article.id)) for article in feed.entries ] return upstream_articles
def set_news_section(cls): from feedreader.parser import from_url, ParseError c.articles = [] try: parsed = from_url('http://127.0.0.1/feed') for entry in parsed.entries[:3]: c.articles.append( (str(entry.link).replace('/wp/index.php/noticia/', '/noticia/'), cls.formata_data(entry.published), cls.limita_tamanho(entry.title, 60), cls.limita_tamanho(entry.description, 150))) except ParseError: # nao conseguiu ler o feed, deixe a area de noticias vazia pass
def events_by_category(request, category, cat_id): ENTRIES_PER_PAGE = 5 phillyfun_url = "http://www.phillyfunguide.com/feeds/event/rss" url = "%s/%s/" % (phillyfun_url, cat_id) parsed = from_url(url) entry_list = parsed.entries paginator = Paginator(entry_list, ENTRIES_PER_PAGE) page = request.GET.get('page') try: entries = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. entries = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. entries = paginator.page(paginator.num_pages) return render_to_response('events/get_by_category.html', locals(), context_instance=RequestContext(request))
def collect(self, author, forum, feed_url): feed = from_url(feed_url) for entry in feed.entries: slug = '%s-%s' % (author, slugify(unicode(entry.title))) self.write(author, forum, entry.link, entry.title, entry.description, entry.published, slug)