Module: Vnews::Autodiscoverer

Defined in:
lib/vnews/autodiscoverer.rb

Instance Method Summary collapse

Instance Method Details

#auto_discover(feed_url) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/vnews/autodiscoverer.rb', line 7

def auto_discover(feed_url)
  html = open(feed_url)
  doc = Nokogiri::HTML.parse(html)
  feed_url = [ 'head link[@type=application/atom+xml]', 
    'head link[@type=application/rss+xml]', 
    "head link[@type=text/xml]"].detect do |path|
      doc.at(path)
    end
  if feed_url
    feed_url
  else
    nil
  end
rescue Errno::ECONNRESET, Nokogiri::CSS::SyntaxError
  $stderr.puts $!
end