Last active
May 27, 2024 01:21
-
-
Save LevitatingBusinessMan/cd7d44632d0c54a03703a11dec53254e to your computer and use it in GitHub Desktop.
RSS Galnet
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 'nokogiri' | |
require 'open-uri' | |
require 'rss' | |
URL = URI("https://community.elitedangerous.com/") | |
doc = Nokogiri::HTML(URL.open) | |
articles = doc.css("div.article").map {|article| [ | |
article.css("h3.galnetNewsArticleTitle a").first.content.strip, #title | |
article.css("h3.galnetNewsArticleTitle a").first.attr("href").strip, #link | |
article.css("div.i_right + p").first.content.strip, #body | |
article.css("div.i_right p").first.content.strip #date | |
]} | |
rss = RSS::Maker.make("rss2.0") do |maker| | |
maker.channel.title = "Galnet News" | |
maker.channel.link = URL.to_s | |
maker.channel.description = "Galnet News" | |
for article in articles | |
title, link, body, date = article | |
maker.items.new_item do |item| | |
item.title = title | |
item.link = URL + link | |
item.description = body | |
item.pubDate = date | |
end | |
end | |
end | |
puts rss |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment