在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):feedjira/feedjira开源软件地址(OpenSource Url):https://github.com/feedjira/feedjira开源编程语言(OpenSource Language):Ruby 100.0%开源软件介绍(OpenSource Introduction):FeedjiraFeedjira is a Ruby library designed to parse feeds. InstallationAdd this line to your application's Gemfile: gem "feedjira" ParsingAn example of parsing a feed with Feedjira: xml = HTTParty.get(url).body
feed = Feedjira.parse(xml)
feed.entries.first.title
# => "Announcing version 3.0" Specifying parserIf you have the XML and just want to provide a parser class for one parse, you
can specify that using Feedjira.parse(xml, parser: MyAwesomeParser) Adding attributes to all feeds types / all entries types# Add the generator attribute to all feed types
Feedjira::Feed.add_common_feed_element("generator")
xml = HTTParty.get("http://www.pauldix.net/atom.xml").body
Feedjira.parse(xml).generator
# => "TypePad" Adding attributes to only one classIf you want to add attributes for only one class you simply have to declare them in the class # Add some GeoRss information
class Feedjira::Parser::RSSEntry
element "georss:elevation", as: :elevation
end
# Fetch a feed containing GeoRss info and print them
url = "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/significant_week.atom"
xml = HTTParty.get(url).body
Feedjira.parse(xml).entries.each do |entry|
puts "Elevation: #{entry.elevation}"
end ConfigurationParsersAdding a custom parserYou can insert your own parser at the front of the available parser list by: Feedjira.configure do |config|
config.parsers.unshift(MyAwesomeParser)
end Now when you call Explicitly set all available parsersFeedjira can be configured to use a specific set of parsers and in a specific order: Feedjira.configure do |config|
config.parsers = [
Feedjira::Parser::ITunesRSS,
MyAwesomeParser,
Feedjira::Parser::RSS
]
end Stripping whitespace from XMLFeedjira can be configured to strip all whitespace but defaults to lstrip only: Feedjira.configure do |config|
config.strip_whitespace = true
end ContributingBug reports and pull requests are welcome on GitHub at https://github.com/feedjira/feedjira. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct. Projects that use FeedjiraFeedjira is used in some awesome projects around the web - from RSS readers to add-ons and everything in between. Here are some of them:
Note: to get your project on this list, simply send an email with your project's details. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论