Feedbag is Ruby's favorite feed auto-discovery tool/library!
>> require "feedbag"
=> true
>> Feedbag.find "damog.net/blog"
=> ["http://damog.net/blog/atom.xml"]
>> Feedbag.feed? "google.com"
=> false
>> Feedbag.feed?("https://daringfireball.net/feeds/main")
=> true$ gem install feedbag
Or just grab feedbag.rb and use it on your own project:
$ wget https://raw.githubusercontent.com/damog/feedbag/master/lib/feedbag.rb
You can also use the command line tool for quick queries, if you install the gem:
» feedbag https://www.ruby-lang.org/en/
== https://www.ruby-lang.org/en/:
- https://www.ruby-lang.org/en/feeds/news.rss
Feedbag will find RSS, Atom, and JSON feed types:
>> Feedbag.find('https://daringfireball.net')
=> ["https://daringfireball.net/feeds/main", "https://daringfireball.net/feeds/json"]Feedbag defaults to a User-Agent string of Feedbag/VERSION, but you can override it:
>> Feedbag.find('https://kottke.org', 'User-Agent' => "My Personal Agent/1.0.1")
=> ["http://feeds.kottke.org/main"]Other options passed to find will be forwarded to OpenURI:
Feedbag.find("https://example.com", 'User-Agent' => "My Agent/1.0", open_timeout: 10)See OpenURI options for more details.
By default, errors are written to $stderr. You can redirect them to a custom logger:
# Use Rails logger
Feedbag.logger = Rails.logger
# Or silence all output
Feedbag.logger = Logger.new('/dev/null')Feedbag handles internationalized URLs (IRIs) with non-ASCII characters:
>> Feedbag.find("https://example.com/中文/feed/")
# Works! URLs are automatically normalized- Because it only uses Nokogiri and Addressable as dependencies.
- Because it follows modern feed filename conventions (like those ones used by WordPress blogs, or Blogger, etc).
- Because it's a single file you can embed easily in your application.
- Because it handles international URLs with non-ASCII characters.
- Because it's faster than anything else.
David Moreno <damog@damog.net>.
Superfeedr has kindly financially supported the development of Feedbag.
This is and will always be free software. See COPYING for more information.
