module Automatic::FeedParser
Public Class Methods
get_url(url)
click to toggle source
# File lib/automatic/feed_parser.rb, line 14 def self.get_url(url) begin unless url.nil? Automatic::Log.puts("info", "Parsing Feed: #{url}") feed = URI.parse(url).normalize open(feed) {|http| response = http.read RSS::Parser.parse(response, false) } end rescue => e raise e end end
parse_html(html)
click to toggle source
# File lib/automatic/feed_parser.rb, line 29 def self.parse_html(html) RSS::Maker.make("2.0") {|maker| xss = maker.xml_stylesheets.new_xml_stylesheet maker.channel.title = "Automatic Ruby" maker.channel.description = "Automatic::FeedParser" maker.channel.link = "https://github.com/automaticruby/automaticruby" maker.items.do_sort = true doc = Nokogiri::HTML(html) (doc/:a).each {|link| unless link[:href].nil? item = maker.items.new_item item.title = "Automatic Ruby" item.link = link[:href] item.date = Time.now item.description = "" end } } end