Skip to content

Instantly share code, notes, and snippets.

@peterc
Created March 29, 2019 23:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterc/d73345db00f801e217df0665939ec189 to your computer and use it in GitHub Desktop.
Save peterc/d73345db00f801e217df0665939ec189 to your computer and use it in GitHub Desktop.
Cooperpress issues to item-based RSS
require 'open-uri'
require 'json'
require 'nokogiri'
require 'rss'
URL = "https://javascriptweekly.com/issues/latest.json"
issue_data = JSON.parse(open(URL).read)
issue = Nokogiri::HTML(issue_data['xml_body'])
rss = RSS::Maker.make("2.0") do |maker|
maker.channel.title = "JavaScript Weekly"
maker.channel.link = URL
maker.channel.description = ""
issue.css("item").each do |item|
maker.items.new_item do |rss_item|
rss_item.title = item.attr('title')
rss_item.link = item.attr('url')
rss_item.description = item.inner_html
end
end
end
puts rss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment