Read news from Ansa 🗞
Add to your Gemfile
gem 'ansa'
Import using
require 'ansa'
Get all the news about soccer
news = Ansa::get_soccer_news()
puts news[0].title
You can also use get_news
method, specifying the category you want
news = Ansa::get_news(Ansa::SOCCER)
For more methods see the documentation.
require 'ansa'
puts "\n⚽️ SOCCER NEWS ⚽️\n\n"
begin
Ansa::get_soccer_news.each do |news|
puts "🥅 [#{news.date.strftime("%d/%m %H:%M:%S")}] #{news.title}"
puts news.description
puts "\n"
end
rescue Ansa::AnsaError
puts "🚨 Something went wrong, news not available"
end