Ruby

How to Retrieve RSS in Ruby

A template for retrieving RSS in Ruby and outputting it to a file. Retrieves title and link tags. Useful for information gathering in scraping purposes.

Shou Arisaka
1 min read
Nov 6, 2025

Overview

A template for retrieving RSS in Ruby and outputting it to a file. Retrieves title and link tags.

Useful for information gathering in scraping purposes. For example, if it's an article, you could perform morphological analysis on what you retrieve and extract keywords.

Template

require 'rss'

###filename URL of the RSS you want to retrieve
###filenames Any file name

filename = 'https://yuis-programming.com/feed'        ##URL of the RSS you want to retrieve
rss = RSS::Parser.parse(filename)
rss.items.each{|item|
  puts title = item.title
  puts link = item.link
  #puts des = item.description

    filenames = "rss"        ##Any file name
    File.open("C:" + filenames + ".txt", "a") do |f|  #Error if the destination file is open in an editor
    #f.puts item.title
    f.puts title
    f.puts link
    #f.puts des
    end

}

Error Countermeasure

C:/Ruby23-x64/lib/ruby/2.3.0/net/http.rb:933:in `connect_nonblock': SSL_connect returned=1 errno=0 state=error: certificate verify failed (OpenSSL::SSL::SSLError)

If you get the above error, changing the url from "https://" to "http://" should work.

※There may be security issues. Please use at your own risk on trusted sites.

Share this article

Shou Arisaka Nov 6, 2025

🔗 Copy Links