Google ニュースの RSS からタイトルを取得します。
google_news_title.rb
require 'rss'
# 検索ジャンル (以下のいづれか)
# WORLD, NATION, BUSINESS, TECHNOLOGY, ENTERTAINMENT, SPORTS,
# SCIENCE, HEALTH
SEARCH = 'TECHNOLOGY'
def encode_url(url)
URI.encode url.encode('EUCJP')
end
url =
"https://news.google.com/rss/search?q=#{SEARCH}&hl=ja&gl=JP&ceid=JP:ja"
RSS::Parser.parse(encode_url(url), true, false).channel.items.each do |item|
puts item.title
end