Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

feed_parser

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

feed_parser

  • 0.3.5
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

FeedParser

Rss and Atom feed parser built on top of Nokogiri. Supports custom sanitizers.

Build Status

Build Status

FeedParser gem is tested on Ruby 1.9.3 and 2.0.0. 1.8.7 should work with Nokogiri < 1.6.0.

Install

Add to Gemfile

gem "feed_parser"

Usage

Parse from URL
fp = FeedParser.new(:url => "http://example.com/feed/")
feed = fp.parse

Optionally pass HTTP options, see more from the OpenURI documentation: http://apidock.com/ruby/OpenURI

fp = FeedParser.new(:url => "http://example.com/feed/", :http => {:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE})
Parse from an XML string
fp = FeedParser.new(:feed_xml => "<rss>...</rss>")
feed = fp.parse
Use sanitizer
fp = FeedParser.new(:url => "http://example.com/feed/", :sanitizer => MyBestestSanitizer.new)
# sanitizing custom field set
fp = FeedParser.new(:url => "http://example.com/feed/", :sanitizer => MyBestestSanitizer.new, :fields_to_sanitize => [:title, :content])
Using parsed feed in your code
feed.as_json
# => {:title => "Feed title", :url => "http://example.com/feed/", :items => [{:guid => , :title => , :author => ...}]}

feed.items.each do |feed_item|
  pp feed_item
end

If the XML is not a valid RSS or an ATOM feed, a FeedParser::UnknownFeedType is raised in FeedParser#parse.

Running tests

Install dependencies:

$ gem install bundler
$ bundle install

Run rspec tests:

$ bundle exec rake spec

Contributing

Fork, hack, push, create a pull request.

FAQs

Package last updated on 26 Jul 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc