add code
This commit is contained in:
commit
61f22217ca
2 changed files with 46 additions and 0 deletions
42
main.rb
Normal file
42
main.rb
Normal file
|
@ -0,0 +1,42 @@
|
|||
require 'rss'
|
||||
require 'nokogiri'
|
||||
require 'open-uri'
|
||||
|
||||
doc = Nokogiri::HTML(URI.open("https://colean.cc/journal/2021/index.html"))
|
||||
titles = []
|
||||
locs = []
|
||||
|
||||
doc.css('a').each do |link|
|
||||
if link.content.include? "[.., d]"
|
||||
else
|
||||
titles << link.content
|
||||
locs << "https://colean.cc/journal/2021/" + link['href']
|
||||
end
|
||||
end
|
||||
|
||||
titles = titles.reverse
|
||||
locs = locs.reverse
|
||||
|
||||
feed = RSS::Maker.make("rss2.0") do |maker|
|
||||
maker.channel.author = "QDFM"
|
||||
maker.channel.updated = Time.now.to_s
|
||||
maker.channel.about = "https://colean.cc/journal/rss.xml"
|
||||
maker.channel.title = "The Journal"
|
||||
maker.channel.description = "The trihosted thoughts of Celeste"
|
||||
maker.channel.link = "https://colean.cc/journal"
|
||||
|
||||
i = -1
|
||||
loop do
|
||||
i = i + 1
|
||||
maker.items.new_item do |item|
|
||||
item.link = locs[i]
|
||||
item.title = titles[i]
|
||||
item.updated = Time.now.to_s
|
||||
end
|
||||
if i == titles.length - 1
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
puts feed
|
4
readme.md
Normal file
4
readme.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Quick and Dirty Feed Maker
|
||||
|
||||
Was looking for a basic RSS feed generator when someone recommended I use the rss gem in ruby.
|
||||
This is horrid but it works even though I've never written Ruby code in my life.
|
Reference in a new issue