0.0
No release in over 3 years
Get Google News headlines from Ruby or the command line.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 2.7.1
~> 1.1.8
~> 0.6.3
~> 0.15.2
~> 12.0
~> 3.0
~> 1.18

Runtime

>= 0.1.0
>= 0.2.6
 Project Readme

google_news

Gem downloads License: MIT

Unofficial Ruby gem to get Google News RSS feeds easily from Ruby or the command line.

Inspired by google-news-js.

Warning

Early alpha release. Use with caution.

TODOs:

  • CLI
    • Support at all
    • Support for different output formats (json, text, ...)
  • More tests
  • More documentation

Contents

  • Common information
  • Installation
  • Usage
  • Command line
  • Documentation
  • Contributing

Common information

This is just a simple RSS feed parser for Google News RSS feeds.

Can also be used from the command line!

There is support for:

  • Top stories
  • News by topic
  • News by location
  • News by keyword
  • News by source
  • News by language

Installation

Ruby

Add this line to your application's Gemfile:

gem 'google_news'

And then execute:

bundle install

Command line

If you just want to use the command line then run

gem install google_news

Usage

require 'google_news'

results = GoogleNews.headlines n: 5 # get top 5 news in default language (country: us, language: en)
puts results
# => [
# {
#   :title =>    "Title of the news article", 
#   :link =>     "https://link.to/the/article", 
#   :pub_date => Time("Wed, 01 Jan 2024 00:00:00 GMT"), 
#   :descriptions => [
#     {
#       :title => "First article, like :title",
#       :link => "https://link.to/the/first/article",
#       :author => "Author Name",
#     },
#    {
#      :title => "Second article, same topic, similiar to first",
#      :link => "https://link.to/the/second/article",
#     :author => "Another Author Name",
#    },
#    ...
#  ],
# ]

Command line

google_news is also available on the command line after installation.

The results are printed in JSON format by default.

$ google_news --help
Usage: google_news [options]
    -n, --number NUMBER                Number of news articles to fetch (default: 10)
    -c, --country COUNTRY              Country code (default: 'us')
    -l, --language LANGUAGE            Language code (default: 'en')
    -t, --topic TOPIC                  News topic (e.g., 'world', 'business', 'technology', etc.)
    -s, --source SOURCE                News source (e.g., 'bbc-news', 'cnn', etc.)
    -k, --keyword KEYWORD              Keyword to search for in news articles
    -f, --format FORMAT                Output format: 'json' (default) or 'text'
    -h, --help                         Show this help message

Examples

Fetch top 5 news articles in the default language (country: us, language: en):

$ google_news -n 5

Documentation

Detailed (code) documentation is available at https://www.rubydoc.info/gems/google_news.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/magynhard/google_news. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.