Pulling in an RSS feed

I am trying to use anonyfox:scrape mainly because it has the most app installs from what I can see. However, there is not much documentation behind it and I cannot find any posts about this package in specific. I am trying to pull a feed from http://na.leagueoflegends.com/en/rss.xml and I am getting the error below. I know I will probably need to display these somehow in my template/view too, but cannot get that far. How can I pull these feeds in and display them in my app? The feeds will be displayed at /news

 While processing files with ecmascript (for target os.windows.x86_32):
   server/main.js:9:23: Unexpected token (9:23)

=> Your application has errors. Waiting for file change.

Thanks in advance!

And what does line 9 of server/main.js look like?

feedData = Scrape.feed “http://na.leagueoflegends.com/en/rss.xm”

I think you need parentheses (and possibly check that rss.xm too):

feedData = Scrape.feed("http://na.leagueoflegends.com/en/rss.xml");

may be what you’re after.

EDIT: To clarify - it looks like the package author is showing examples in coffescript.

That is super helpful, I’ll try that out! How can I get the feed to display in my template (assuming I can pull the feed)

Well, first you’ll need to convert the xml into something usable (i.e. a JavaScript object) and then, assuming you’re pulling the feed from the server, you need to get it to the client. There are at least three obvious ways to do that:

  1. “Pull” from the client using a Meteor.call, with a corresponding Method on the server. Requires a timer on the client to pull at regular intervals. Easy to understand, but won’t scale very well.
  2. Insert the rss data (as JavaScript objects) into a MongoDB collection. Use Meteor’s pub/sub mechanism to deliver new data as it arrives. Requires a timer on the server to ensure regular updates. Scales reasonably well and provides a persistent history of feeds.
  3. Pull from the server and use the low-level pub/sub API to deliver results to the client. Requires similar mechanics to option 2, but scales better (no oplog tailing), but won’t automatically provide a persistent history.
1 Like