views:

266

answers:

2

I'm using the feedparser library in python to retrieve news from a local newspaper (my intent is to do Natural Language Processing over this corpus) and would like to be able to retrieve many past entries from the RSS feed.

I'm not very acquainted with the technical issues of RSS, but I think this should be possible (I can see that, e.g., Google Reader and Feedly can do this ''on demand'' as I move the scrollbar).

When I do the following:

import feedparser

url = 'http://feeds.folha.uol.com.br/folha/emcimadahora/rss091.xml'
feed = feedparser.parse(url)
for post in feed.entries:
   title = post.title

I get only a dozen entries or so. I was thinking about hundreds. Maybe all entries in the last month, if possible. Is it possible to do this only with feedparser?

I intend to get from the rss feed only the link to the news item and parse the full page with BeautifulSoup to obtain the text I want. An alternate solution would be a crawler that follows all local links in the page to get a lot of news items, but I want to avoid that for now.

--

One solution that appeared is to use the Google Reader RSS cache:

http://www.google.com/reader/atom/feed/http%3A//feeds.folha.uol.com.br/folha/emcimadahora/rss091.xml?n=1000

But to access this I must be logged in to Google Reader. Anyone knows how I do that from python? (I really don't know a thing about web, I usually only mess with numerical calculus).

+4  A: 

You're only getting a dozen entries or so because that's what the feed contains. If you want historic data you will have to find a feed/database of said data.

Check out this ReadWriteWeb article for some resources on finding open data on the web.

Note that Feedparser has nothing to do with this as your title suggests. Feedparser parses what you give it. It can't find historic data unless you find it and pass it into it. It is simply a parser. Hope that clears things up! :)

Bartek
Thanks again Bartek. I think I understand it better now. So the RSS is simply a xml file stored in the server? I had the wrong image about it... thought it was kind of a ''protocol'' to get a text feed. Thanks again.
Rafael S. Calsaverini
+3  A: 

To expand on Bartek's answer: You could also start storing all of the entries in the feed that you've already seen, and build up your own historical archive of the feed's content. This would delay your ability to start using it as a corpus (because you'd have to do this for a month to build up a collection of a month's worth of entries), but you wouldn't be dependent on anyone else for the data.

I may be mistaken, but I'm pretty sure that's how Google Reader can go back in time: They have each feed's past entries stored somewhere.

Will McCutchen
Hummm... I guess the way to go then is to get the feed from Google Reader itself, maybe?
Rafael S. Calsaverini
It seems that Google Reader itself can be used to retrieve a historical list of items! :Dhttp://googlesystem.blogspot.com/2007/06/reconstruct-feeds-history-using-google.html
Rafael S. Calsaverini
I just discovered this, too. Here's the last 100 items in the feed you're interested in: http://www.google.com/reader/atom/feed/http://feeds.folha.uol.com.br/folha/emcimadahora/rss091.xml?n=1000
Will McCutchen
Problem is: I must login to google reader to be able to access this... Tried to use feedparser and only managed to get a empty entry list.Anyone knows how could I login to google reader from python to download this entry list?I really know nothing
Rafael S. Calsaverini
Hummm... this answer from stackoverflow helped:http://stackoverflow.com/questions/52880/google-reader-api-unread-count
Rafael S. Calsaverini