Created
October 1, 2012 06:44
-
-
Save evenchange4/3809903 to your computer and use it in GitHub Desktop.
ROR RSS parse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: UTF-8 | |
require 'uri' | |
require 'feedzirra' | |
require 'open-uri' | |
class LivefeedController < ApplicationController | |
def livefeed | |
q = '宏達電' | |
url = URI.escape("https://news.google.com/news/feeds?q="+q+"&output=rss&num=90") | |
# fetching a single feed | |
@feed = Feedzirra::Feed.fetch_and_parse(url) | |
@entries = @feed.entries | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<span><a href='<%=@feed.url%>'><%= @feed.title %></a></span> | |
<span><a href='<%=@feed.feed_url%>'>RSS url</a></span> | |
<span>etag: <%= @feed.etag %></span> | |
<span>last_modified: <%= @feed.last_modified %></span> | |
<hr> | |
<% @entries.each do|e|%> | |
<div class='content'> | |
<a href='<%=e.url%>' class='title'><%= e.title %></a><%= e.published %> | |
<%= e.summary.html_safe %> | |
</div> | |
<hr> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment