Created
March 29, 2019 23:15
-
-
Save peterc/d73345db00f801e217df0665939ec189 to your computer and use it in GitHub Desktop.
Cooperpress issues to item-based RSS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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