Created
January 21, 2016 13:30
-
-
Save tujlaky/e0d5971524f57009d49b to your computer and use it in GitHub Desktop.
Get arch linux RSS
This file contains hidden or 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
#!/usr/local/rvm/wrappers/ruby-2.1.1/ruby | |
# encoding: UTF-8 | |
require 'rss' | |
require 'open-uri' | |
require 'i18n' | |
I18n.backend.store_translations :hu, { | |
:date => { | |
:formats => { | |
:default => "%Y.%m.%d" | |
}, | |
:month_names => %w(január február március április május június július augusztus szeptember október november december).unshift(nil) | |
} | |
} | |
I18n.config.enforce_available_locales = false | |
# Class to get arch linux rss feed | |
class ArchRss | |
attr_accessor :url | |
def initialize(url) | |
@url = url | |
end | |
def fetch_rss | |
open(@url) do |rss| | |
feed = RSS::Parser.parse(rss) | |
first=feed.items.first | |
puts first.title | |
puts I18n::localize(first.pubDate, :format => '%Y. %B %d. %H:%M', :locale => 'hu') | |
end | |
end | |
end | |
rss=ArchRss.new('https://www.archlinux.org/feeds/news/') | |
rss.fetch_rss |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment