Advanced Feed Parsing in Rails

2019-09-01 03:29发布

I am a newbie to rails and I have been watching Rails Casts videos.

I am interested to know a little bit more on FeedZirra (Rails casts episode 168) and especially feed parsing.

For example, I need to Parse feeds from Telegraph and Guardian

I want to put all the sports news from both the newspapers in one table, just football news in another table, cricket news in another table etc

How can I achieve that using feed-zirra?

How do I display only football news in one view and only cricket news in another view?

Also, I want the user to know which website he is gonna visit before he actually clicks the link and finds out.

Something like this

Ryder Cup 2010: Graeme McDowell the perfect hero for Europe 5 min ago | Telegraph.co.uk

How do I display Telegraph.co.uk

Looking forward for your help and support

Thanks

1条回答
神经病院院长
2楼-- · 2019-09-01 03:47

There are many questions there, but I'll take this one:

I just know how to put all feeds in table. I dont know how to keep feeds in different tables

  • Create different models to suit your data model, based on what information you need to show rather than what is provided in the feed. (Different tables for each models if required or Single Table Inheritance if possible)
  • Write a wrapper class that will use FeedZirra (or any other parser for that matter) to read the parsed feeds and process them. These are generally kept in the lib folder.
  • Create a rake task which can be called to run this script OR if you are familiar with delayed_job, then create a job.
  • Schedule your rake task through cron or your job through delayed_job, so that you can periodically update your data.
查看更多
登录 后发表回答