Module: Automatic::FeedParser
- Defined in:
- lib/automatic/feed_parser.rb
Class Method Summary collapse
Class Method Details
.get_url(url) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/automatic/feed_parser.rb', line 15 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) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/automatic/feed_parser.rb', line 30 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 |