0
0

More than 3 years have passed since last update.

Get News Titles from Google News

Last updated at Posted at 2020-01-26

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

実行結果

google_news_title.jpg

参考にしたページ

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0