ranahaani/GNews

A Happy and lightweight Python Package that Provides an API to search for articles on Google News and returns a JSON response.

Python

1,017

177 commits

updated Oct 9, 2026

See the code

README

Contributors Forks Stargazers Issues MIT License Download LinkedIn Docs



Sponsored by SearchApi — Google News API

Sponsored by SearchApi

Related: gnews-agent — persistent, semantic news intelligence for AI agents, built on GNews. Fetch, dedupe, embed, and query articles from Python, a CLI, or an MCP server. pip install gnews-agent · guide


GNews

GNews 📰

A Happy and lightweight Python Package that Provides an API to search for articles on Google News and returns a usable JSON response! 🚀
If you like ❤️ GNews or find it useful 🌟, support the project by buying me a coffee ☕.
Buy Me A Coffee

🚀 View Demo · 🐞 Report Bug · 🚀 Request Feature

Table of Contents 📑
  1. About 🚩
  2. Getting Started 🚀
  3. Usage 🧩
  4. SearchApi Integration 🔍
  5. Using GNews Behind a Proxy 🛡️
  6. Related: gnews-agent
  7. To Do 📋
  8. Roadmap 🛣️
  9. Contributing 🤝
  10. License ⚖️
  11. Contact 📬
  12. Acknowledgements 🙏

About GNews

🚩 GNews is A Happy and lightweight Python Package that searches Google News RSS Feed and returns a usable JSON response
🚩 As well as you can fetch full article (No need to write scrappers for articles fetching anymore)
🚩 Scraping a lot of articles and your IP keeps getting blocked? Route GNews requests through RapidProxy residential proxies to keep pulling full articles without getting rate-limited. GNews users get 10% off with code RAPID10.

RapidProxy — Residential and ISP Proxies for Web Scraping

Try RapidProxy — 90M+ residential IPs with smart rotation, sticky sessions and non-expiring traffic, from $0.55/GB. Get 10% off with code RAPID10.

Google News cover across 141+ countries with 41+ languages. On the bottom left side of the Google News page you may find a Language & region section where you can find all of the supported combinations.

Demo

GNews Demo

Getting Started

This section provides instructions for two different use cases:

  1. Installing the GNews package for immediate use.
  2. Setting up the GNews project for local development.

1. Installing the GNews package

To install the package and start using it in your own projects, follow these steps:

pip install gnews

To also enable full article text extraction:

pip install gnews[fulltext]

To enable real article URL resolution (resolves Google News redirect URLs):

pip install gnews[playwright]
playwright install chromium

2. Setting Up GNews for Local Development

If you want to make modifications locally, follow these steps to set up the development environment.

Option 1: Setup with Docker

  1. Install docker and docker-compose.
  2. Configure the .env file by placing your MongoDB credentials.
  3. Run the following command to build and start the Docker containers:
docker-compose up --build

Option 2: Install Using Git Clone

  1. Clone this repository:
git clone https://github.com/ranahaani/GNews.git
  1. Set up a virtual environment:
virtualenv venv
source venv/bin/activate  # MacOS/Linux
.\venv\Scripts\activate  # Windows
  1. Install the required dependencies:
pip install -r requirements.txt

Example usage

from gnews import GNews

google_news = GNews()
pakistan_news = google_news.get_news('Pakistan')
print(pakistan_news[0])
[{
'publisher': 'Aljazeera.com',
 'description': 'Pakistan accuses India of stoking conflict in Indian Ocean  '
                'Aljazeera.com',
 'published date': 'Tue, 16 Feb 2021 11:50:43 GMT',
 'title': 'Pakistan accuses India of stoking conflict in Indian Ocean - '
          'Aljazeera.com',
 'url': 'https://www.aljazeera.com/news/2021/2/16/pakistan-accuses-india-of-nuclearizing-indian-ocean'
 },
 ...]

📘 Interactive Tutorial

We have created a step-by-step [ jupyter Notebook tutorial ] that demonstrates:

  • Basic usage and setup
  • Filtering news (by topic, location, domain, date range, etc.)
  • Exporting results (CSV, JSON)
  • Real-world analysis: Sentiment Analysis on news headlines
  • Advanced usage & best practices
  • Interactive examples you can run line-by-line

👉 Open the tutorial here:
examples/tutorial.ipynb

This is the best way to learn GNews hands-on.

Get top news

  • GNews.get_top_news()

Get news by keyword

  • GNews.get_news(keyword)

Get news by major topic

  • GNews.get_news_by_topic(topic)
  • Available topics: WORLD, NATION, BUSINESS, TECHNOLOGY, ENTERTAINMENT, SPORTS, SCIENCE, HEALTH, POLITICS, CELEBRITIES, TV, MUSIC, MOVIES, THEATER, SOCCER, CYCLING, MOTOR SPORTS, TENNIS, COMBAT SPORTS, BASKETBALL, BASEBALL, FOOTBALL, SPORTS BETTING, WATER SPORTS, HOCKEY, GOLF, CRICKET, RUGBY, ECONOMY, PERSONAL FINANCE, FINANCE, DIGITAL CURRENCIES, MOBILE, ENERGY, GAMING, INTERNET SECURITY, GADGETS, VIRTUAL REALITY, ROBOTICS, NUTRITION, PUBLIC HEALTH, MENTAL HEALTH, MEDICINE, SPACE, WILDLIFE, ENVIRONMENT, NEUROSCIENCE, PHYSICS, GEOLOGY, PALEONTOLOGY, SOCIAL SCIENCES, EDUCATION, JOBS, ONLINE EDUCATION, HIGHER EDUCATION, VEHICLES, ARTS-DESIGN, BEAUTY, FOOD, TRAVEL, SHOPPING, HOME, OUTDOORS, FASHION.

Get news by geo location

  • GNews.get_news_by_location(location)
  • location can be name of city/state/country

Get news by site

  • GNews.get_news_by_site(site)
  • site should be in the format of: "cnn.com"

Results specification

All parameters are optional and can be passed during initialization. Here’s a list of the available parameters:

  • language: The language in which to return results (default: 'en').
  • country: The country code for the headlines (default: 'US').
  • period: The time period for which you want news.
  • start_date: Date after which results must have been published.
  • end_date: Date before which results must have been published.
  • max_results: The maximum number of results to return (default: 100).
  • exclude_websites: A list of websites to exclude from results.
  • max_retries: Retry attempts on HTTP 429 from Google News (default: 3). Set to 0 to disable retries.
  • retry_backoff_base: Base seconds for exponential backoff between retries (default: 1.0). Effective delay is min(retry_backoff_max, retry_backoff_base * 2 ** attempt) plus uniform jitter in [0, retry_backoff_base).
  • retry_backoff_max: Cap (in seconds) for any single backoff delay (default: 60.0).
  • proxy: A dictionary specifying the proxy settings used to route requests. The dictionary should contain a single key-value pair where the key is the protocol (http or https) and the value is the proxy address. Example:
# Example with only HTTP proxy
  proxy = {
      'http': 'http://your_proxy_address',
  }
  
# Example with only HTTPS proxy
  proxy = {
      'https': 'http://your_proxy_address',
  }

Example Initialization

from gnews import GNews

# Initialize GNews with various parameters, including proxy
google_news = GNews(
    language='en',
    country='US',
    period='7d',
    start_date=None,
    end_date=None,
    max_results=10,
    exclude_websites=['yahoo.com', 'cnn.com'],
    proxy={
        'https': 'https://your_proxy_address'
    }
)
  • Or change it to an existing object
google_news.period = '7d'  # News from last 7 days
google_news.max_results = 10  # number of responses across a keyword
google_news.country = 'United States'  # News from a specific country 
google_news.language = 'english'  # News in a specific language
google_news.exclude_websites = ['yahoo.com', 'cnn.com']  # Exclude news from specific website i.e Yahoo.com and CNN.com
google_news.start_date = (2020, 1, 1) # Search from 1st Jan 2020
google_news.end_date = (2020, 3, 1) # Search until 1st March 2020

The format of the timeframe is a string comprised of a number, followed by a letter representing the time operator. For example 1y would signify 1 year. Full list of operators below:

 - h = hours (eg: 12h)
 - d = days (eg: 7d)
 - m = months (eg: 6m)
 - y = years (eg: 1y)

Setting the start and end dates can be done by passing in either a datetime or a tuple in the form (YYYY, MM, DD).

Supported Countries

print(google_news.AVAILABLE_COUNTRIES)

{'Australia': 'AU', 'Botswana': 'BW', 'Canada ': 'CA', 'Ethiopia': 'ET', 'Ghana': 'GH', 'India ': 'IN',
 'Indonesia': 'ID', 'Ireland': 'IE', 'Israel ': 'IL', 'Kenya': 'KE', 'Latvia': 'LV', 'Malaysia': 'MY', 'Namibia': 'NA',
 'New Zealand': 'NZ', 'Nigeria': 'NG', 'Pakistan': 'PK', 'Philippines': 'PH', 'Singapore': 'SG', 'South Africa': 'ZA',
 'Tanzania': 'TZ', 'Uganda': 'UG', 'United Kingdom': 'GB', 'United States': 'US', 'Zimbabwe': 'ZW',
 'Czech Republic': 'CZ', 'Germany': 'DE', 'Austria': 'AT', 'Switzerland': 'CH', 'Argentina': 'AR', 'Chile': 'CL',
 'Colombia': 'CO', 'Cuba': 'CU', 'Mexico': 'MX', 'Peru': 'PE', 'Venezuela': 'VE', 'Belgium ': 'BE', 'France': 'FR',
 'Morocco': 'MA', 'Senegal': 'SN', 'Italy': 'IT', 'Lithuania': 'LT', 'Hungary': 'HU', 'Netherlands': 'NL',
 'Norway': 'NO', 'Poland': 'PL', 'Brazil': 'BR', 'Portugal': 'PT', 'Romania': 'RO', 'Slovakia': 'SK', 'Slovenia': 'SI',
 'Sweden': 'SE', 'Vietnam': 'VN', 'Turkey': 'TR', 'Greece': 'GR', 'Bulgaria': 'BG', 'Russia': 'RU', 'Ukraine ': 'UA',
 'Serbia': 'RS', 'United Arab Emirates': 'AE', 'Saudi Arabia': 'SA', 'Lebanon': 'LB', 'Egypt': 'EG',
 'Bangladesh': 'BD', 'Thailand': 'TH', 'China': 'CN', 'Taiwan': 'TW', 'Hong Kong': 'HK', 'Japan': 'JP',
 'Republic of Korea': 'KR'}

Supported Languages

print(google_news.AVAILABLE_LANGUAGES)

{'english': 'en', 'indonesian': 'id', 'czech': 'cs', 'german': 'de', 'spanish': 'es-419', 'french': 'fr',
 'italian': 'it', 'latvian': 'lv', 'lithuanian': 'lt', 'hungarian': 'hu', 'dutch': 'nl', 'norwegian': 'no',
 'polish': 'pl', 'portuguese brasil': 'pt-419', 'portuguese portugal': 'pt-150', 'romanian': 'ro', 'slovak': 'sk',
 'slovenian': 'sl', 'swedish': 'sv', 'vietnamese': 'vi', 'turkish': 'tr', 'greek': 'el', 'bulgarian': 'bg',
 'russian': 'ru', 'serbian': 'sr', 'ukrainian': 'uk', 'hebrew': 'he', 'arabic': 'ar', 'marathi': 'mr', 'hindi': 'hi',
 'bengali': 'bn', 'tamil': 'ta', 'telugu': 'te', 'malyalam': 'ml', 'thai': 'th', 'chinese simplified': 'zh-Hans',
 'chinese traditional': 'zh-Hant', 'japanese': 'ja', 'korean': 'ko'}

Article Properties

  • Get news returns a list of articles with the following keys:

RSS backend (default):

FieldDescriptionExample
titleArticle title"Pakistan PM calls for ceasefire"
descriptionShort summary"Pakistan's prime minister said..."
published datePublished date (RFC 2822)"Wed, 07 Jun 2026 07:01:30 GMT"
urlDirect article URL"https://bbc.com/news/..."
publisherPublisher name"BBC News"

SearchApi backend (additional fields):

FieldDescriptionExample
iso_dateISO 8601 publish date"2026-06-07T07:01:30Z"
thumbnailArticle image (base64)"data:image/jpeg;base64,..."
faviconPublisher logo (base64)"data:image/png;base64,..."
rankPosition in search results1

Getting full article

First install the optional dependency:

pip install gnews[fulltext]

Then use get_full_article():

from gnews import GNews

google_news = GNews()
articles = google_news.get_news(‘Pakistan’)
article = google_news.get_full_article(articles[0][‘url’])

print(article[‘text’])   # full article text
print(article[‘url’])    # original URL

Note: Some sites block automated requests (paywalls, Cloudflare). get_full_article() will raise a NetworkError in those cases.

Export Results

Save articles directly to JSON or CSV:

from gnews import GNews

g = GNews(max_results=10)
articles = g.get_news("artificial intelligence")

# Save to JSON
g.save_to_json(articles, "news.json")

# Save to CSV
g.save_to_csv(articles, "news.csv")

Both methods return the output file path. No extra dependencies required.

CLI Usage

GNews includes a command-line interface out of the box:

# Search news
gnews search "artificial intelligence"
gnews search "Pakistan" --lang ur --country PK --max 5

# Top headlines
gnews top
gnews top --max 10

# By topic
gnews topic TECHNOLOGY
gnews topic BUSINESS --max 5

# By site
gnews site bbc.com
gnews site cnn.com --max 3

# By location
gnews location Pakistan
gnews location India --max 5

# JSON output (pipe-friendly)
gnews search "OpenAI" --json
gnews top --json | python3 -m json.tool

Options available on all commands:

OptionDefaultDescription
--langenLanguage code
--countryUSCountry code
--max10Max results
--jsonoffOutput as JSON

Using GNews Behind a Proxy

Google News rate-limits aggressively. If you are pulling more than a few hundred articles, or calling get_full_article() across many domains, you will eventually see HTTP 429s and blocked requests from a single IP.

The fix is to route requests through rotating residential proxies. GNews accepts a standard requests-style proxy dict, so any provider works:

from gnews import GNews

google_news = GNews(
    proxy={
        'http': 'http://YOUR_USERNAME:YOUR_PASSWORD@YOUR_PROXY_HOST:YOUR_PORT',
        'https': 'http://YOUR_USERNAME:YOUR_PASSWORD@YOUR_PROXY_HOST:YOUR_PORT',
    }
)

articles = google_news.get_news('artificial intelligence')

GNews is sponsored by RapidProxy, which is what the maintainer uses for high-volume runs. It offers 90M+ residential IPs, smart rotation, sticky sessions and native static ISP IPs, with traffic that does not expire. Pricing starts at $0.55/GB, and the code RAPID10 gives GNews users 10% off.

from gnews import GNews

RAPIDPROXY = 'http://YOUR_USERNAME:YOUR_PASSWORD@YOUR_PROXY_HOST:YOUR_PORT'

google_news = GNews(
    proxy={'http': RAPIDPROXY, 'https': RAPIDPROXY},
    max_retries=3,
)

articles = google_news.get_news('artificial intelligence')
full = google_news.get_full_article(articles[0]['url'])

Replace YOUR_USERNAME, YOUR_PASSWORD, YOUR_PROXY_HOST and YOUR_PORT with the values generated in your RapidProxy dashboard. Sticky sessions are useful when you want consecutive requests to keep the same exit IP; rotating sessions are better for spreading a large crawl across many IPs.

Tips

  • Keep max_retries at 3 or higher so transient 429s are retried on a fresh IP.
  • Use sticky sessions when fetching an article body, since some sites tie the session to the IP that loaded the page.
  • Residential IPs are slower than datacenter IPs. Increase concurrency rather than expecting each request to be fast.
  • If you would rather skip proxies entirely, the SearchApi backend handles blocking on their side.

SearchApi Integration

GNews supports SearchApi as an optional backend. When a searchapi_key is provided, GNews uses SearchApi instead of the default Google News RSS feed.

Benefits over RSS:

  • Resolved article URLs (fixes broken redirect links, see #62)
  • Pagination beyond the ~100-result RSS cap
  • Richer article data: thumbnail, favicon, iso_date, rank, snippet
  • No IP blocks or rate limits from Google

Setup

pip install gnews

Get a free API key at searchapi.io.

Usage

from gnews import GNews

# Pass your SearchApi key to enable the SearchApi backend
google_news = GNews(searchapi_key="YOUR_SEARCHAPI_KEY")

# All existing methods work as before
articles = google_news.get_news("artificial intelligence")
print(articles[0])
{
  'title': 'OpenAI announces new model',
  'description': 'Article snippet from SearchApi...',
  'published date': '2 hours ago',
  'iso_date': '2026-06-11T10:00:00Z',
  'url': 'https://techcrunch.com/2026/06/11/openai-new-model',
  'publisher': 'TechCrunch',
  'thumbnail': 'data:image/jpeg;base64,...',
  'favicon': 'data:image/png;base64,...',
  'rank': 1
}

Pagination

google_news = GNews(searchapi_key="YOUR_KEY", max_results=50)

# Get page 2 results (breaks past the ~100 RSS cap)
articles = google_news.get_news("Python", page=2)

Additional article fields (SearchApi backend only)

FieldDescription
iso_dateAbsolute ISO 8601 publish date
thumbnailArticle image (base64)
faviconPublisher logo (base64)
rankPosition in search results

The RSS backend (default, no API key required) continues to work exactly as before. The SearchApi backend is fully opt-in.

Async Support

All search methods have async equivalents — no new dependencies required:

import asyncio
from gnews import GNews

g = GNews(max_results=10)

# Single async query
articles = asyncio.run(g.get_news_async("AI"))

# Fetch multiple topics concurrently
async def main():
    ai, python, pakistan = await asyncio.gather(
        g.get_news_async("AI"),
        g.get_news_async("Python"),
        g.get_news_async("Pakistan"),
    )
    return ai, python, pakistan

asyncio.run(main())
Async methodSync equivalent
get_news_async(key, page=1)get_news()
get_top_news_async()get_top_news()
get_news_by_topic_async(topic)get_news_by_topic()
get_news_by_location_async(location)get_news_by_location()
get_news_by_site_async(site)get_news_by_site()

URL Resolution

By default, Google News RSS returns redirect URLs (news.google.com/rss/articles/...) instead of real article URLs. Google requires JavaScript execution to resolve them — plain HTTP requests cannot follow these redirects.

Install the optional Playwright extra to get real article URLs automatically:

pip install gnews[playwright]
playwright install chromium  # one-time setup

Once installed, URL resolution is automatic — no code changes needed:

from gnews import GNews

g = GNews(max_results=5)
articles = g.get_news("AI")

# With gnews[playwright] installed:
print(articles[0]['url'])  # https://www.politico.com/news/...

# Without gnews[playwright]:
print(articles[0]['url'])  # https://news.google.com/rss/articles/...

If resolution fails for a specific article (paywall, timeout, consent gate), GNews falls back to the Google URL silently — it never crashes.

Note: For production use without Playwright, the SearchApi backend always returns real article URLs with zero setup beyond an API key.

gnews-agent (PyPI: gnews-agent) is the sibling package for agents. GNews returns articles. gnews-agent keeps them: it fetches through GNews, deduplicates by title and publisher, embeds the text, and stores it (SQLite + Chroma by default) so later queries are semantic rather than another live search. The same operations — ingest, search, timeline, brief, sentiment, and stats — are available as a Python library, a CLI, and an MCP server for Claude, Cursor, and other clients.

It depends on GNews (gnews>=0.8.2) and installs it for you. ingest, search, timeline, and stats need no API key. brief and sentiment call an LLM.

pip install gnews-agent
from gnews_agent import NewsMemory

memory = NewsMemory()
memory.ingest("OpenAI", method="get_news")
results = memory.search("GPT-5 safety", days=7)
print(results)

Optional extras cover an OpenAI embedding backend (gnews-agent[openai]), full-article text (gnews-agent[fulltext]), and alternate vector stores. The gnews-agent README documents the CLI, the MCP server, and the Claude Code skill. A shorter guide is in these docs: gnews-agent.

Todo

  • Save to MongoDB
  • Save to SQLite
  • Save to JSON ✅
  • Save to .CSV file ✅
  • More than 100 articles ✅
  • Async support ✅
  • Real article URL resolution ✅
  • FastAPI wrapper

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Muhammad Abdullah - @ranahaani - ranahaani@gmail.com

Project Link: https://github.com/ranahaani/GNews

"Buy Me A Coffee"

article
gnews
google-news
google-news-api
google-news-homepage
google-news-rss
google-news-scraper
hacktoberfest
hacktoberfest2025
hacktoberfest-accepted
news
newspaper3k
python
rss-feed

ranahaani/GNews

A Happy and lightweight Python Package that Provides an API to search for articles on Google News and returns a JSON response.

Python

1,017

177 commits

updated Oct 9, 2026

See the code

README

Contributors Forks Stargazers Issues MIT License Download LinkedIn Docs



Sponsored by SearchApi — Google News API

Sponsored by SearchApi

Related: gnews-agent — persistent, semantic news intelligence for AI agents, built on GNews. Fetch, dedupe, embed, and query articles from Python, a CLI, or an MCP server. pip install gnews-agent · guide


GNews

GNews 📰

A Happy and lightweight Python Package that Provides an API to search for articles on Google News and returns a usable JSON response! 🚀
If you like ❤️ GNews or find it useful 🌟, support the project by buying me a coffee ☕.
Buy Me A Coffee

🚀 View Demo · 🐞 Report Bug · 🚀 Request Feature

Table of Contents 📑
  1. About 🚩
  2. Getting Started 🚀
  3. Usage 🧩
  4. SearchApi Integration 🔍
  5. Using GNews Behind a Proxy 🛡️
  6. Related: gnews-agent
  7. To Do 📋
  8. Roadmap 🛣️
  9. Contributing 🤝
  10. License ⚖️
  11. Contact 📬
  12. Acknowledgements 🙏

About GNews

🚩 GNews is A Happy and lightweight Python Package that searches Google News RSS Feed and returns a usable JSON response
🚩 As well as you can fetch full article (No need to write scrappers for articles fetching anymore)
🚩 Scraping a lot of articles and your IP keeps getting blocked? Route GNews requests through RapidProxy residential proxies to keep pulling full articles without getting rate-limited. GNews users get 10% off with code RAPID10.

RapidProxy — Residential and ISP Proxies for Web Scraping

Try RapidProxy — 90M+ residential IPs with smart rotation, sticky sessions and non-expiring traffic, from $0.55/GB. Get 10% off with code RAPID10.

Google News cover across 141+ countries with 41+ languages. On the bottom left side of the Google News page you may find a Language & region section where you can find all of the supported combinations.

Demo

GNews Demo

Getting Started

This section provides instructions for two different use cases:

  1. Installing the GNews package for immediate use.
  2. Setting up the GNews project for local development.

1. Installing the GNews package

To install the package and start using it in your own projects, follow these steps:

pip install gnews

To also enable full article text extraction:

pip install gnews[fulltext]

To enable real article URL resolution (resolves Google News redirect URLs):

pip install gnews[playwright]
playwright install chromium

2. Setting Up GNews for Local Development

If you want to make modifications locally, follow these steps to set up the development environment.

Option 1: Setup with Docker

  1. Install docker and docker-compose.
  2. Configure the .env file by placing your MongoDB credentials.
  3. Run the following command to build and start the Docker containers:
docker-compose up --build

Option 2: Install Using Git Clone

  1. Clone this repository:
git clone https://github.com/ranahaani/GNews.git
  1. Set up a virtual environment:
virtualenv venv
source venv/bin/activate  # MacOS/Linux
.\venv\Scripts\activate  # Windows
  1. Install the required dependencies:
pip install -r requirements.txt

Example usage

from gnews import GNews

google_news = GNews()
pakistan_news = google_news.get_news('Pakistan')
print(pakistan_news[0])
[{
'publisher': 'Aljazeera.com',
 'description': 'Pakistan accuses India of stoking conflict in Indian Ocean  '
                'Aljazeera.com',
 'published date': 'Tue, 16 Feb 2021 11:50:43 GMT',
 'title': 'Pakistan accuses India of stoking conflict in Indian Ocean - '
          'Aljazeera.com',
 'url': 'https://www.aljazeera.com/news/2021/2/16/pakistan-accuses-india-of-nuclearizing-indian-ocean'
 },
 ...]

📘 Interactive Tutorial

We have created a step-by-step [ jupyter Notebook tutorial ] that demonstrates:

  • Basic usage and setup
  • Filtering news (by topic, location, domain, date range, etc.)
  • Exporting results (CSV, JSON)
  • Real-world analysis: Sentiment Analysis on news headlines
  • Advanced usage & best practices
  • Interactive examples you can run line-by-line

👉 Open the tutorial here:
examples/tutorial.ipynb

This is the best way to learn GNews hands-on.

Get top news

  • GNews.get_top_news()

Get news by keyword

  • GNews.get_news(keyword)

Get news by major topic

  • GNews.get_news_by_topic(topic)
  • Available topics: WORLD, NATION, BUSINESS, TECHNOLOGY, ENTERTAINMENT, SPORTS, SCIENCE, HEALTH, POLITICS, CELEBRITIES, TV, MUSIC, MOVIES, THEATER, SOCCER, CYCLING, MOTOR SPORTS, TENNIS, COMBAT SPORTS, BASKETBALL, BASEBALL, FOOTBALL, SPORTS BETTING, WATER SPORTS, HOCKEY, GOLF, CRICKET, RUGBY, ECONOMY, PERSONAL FINANCE, FINANCE, DIGITAL CURRENCIES, MOBILE, ENERGY, GAMING, INTERNET SECURITY, GADGETS, VIRTUAL REALITY, ROBOTICS, NUTRITION, PUBLIC HEALTH, MENTAL HEALTH, MEDICINE, SPACE, WILDLIFE, ENVIRONMENT, NEUROSCIENCE, PHYSICS, GEOLOGY, PALEONTOLOGY, SOCIAL SCIENCES, EDUCATION, JOBS, ONLINE EDUCATION, HIGHER EDUCATION, VEHICLES, ARTS-DESIGN, BEAUTY, FOOD, TRAVEL, SHOPPING, HOME, OUTDOORS, FASHION.

Get news by geo location

  • GNews.get_news_by_location(location)
  • location can be name of city/state/country

Get news by site

  • GNews.get_news_by_site(site)
  • site should be in the format of: "cnn.com"

Results specification

All parameters are optional and can be passed during initialization. Here’s a list of the available parameters:

  • language: The language in which to return results (default: 'en').
  • country: The country code for the headlines (default: 'US').
  • period: The time period for which you want news.
  • start_date: Date after which results must have been published.
  • end_date: Date before which results must have been published.
  • max_results: The maximum number of results to return (default: 100).
  • exclude_websites: A list of websites to exclude from results.
  • max_retries: Retry attempts on HTTP 429 from Google News (default: 3). Set to 0 to disable retries.
  • retry_backoff_base: Base seconds for exponential backoff between retries (default: 1.0). Effective delay is min(retry_backoff_max, retry_backoff_base * 2 ** attempt) plus uniform jitter in [0, retry_backoff_base).
  • retry_backoff_max: Cap (in seconds) for any single backoff delay (default: 60.0).
  • proxy: A dictionary specifying the proxy settings used to route requests. The dictionary should contain a single key-value pair where the key is the protocol (http or https) and the value is the proxy address. Example:
# Example with only HTTP proxy
  proxy = {
      'http': 'http://your_proxy_address',
  }
  
# Example with only HTTPS proxy
  proxy = {
      'https': 'http://your_proxy_address',
  }

Example Initialization

from gnews import GNews

# Initialize GNews with various parameters, including proxy
google_news = GNews(
    language='en',
    country='US',
    period='7d',
    start_date=None,
    end_date=None,
    max_results=10,
    exclude_websites=['yahoo.com', 'cnn.com'],
    proxy={
        'https': 'https://your_proxy_address'
    }
)
  • Or change it to an existing object
google_news.period = '7d'  # News from last 7 days
google_news.max_results = 10  # number of responses across a keyword
google_news.country = 'United States'  # News from a specific country 
google_news.language = 'english'  # News in a specific language
google_news.exclude_websites = ['yahoo.com', 'cnn.com']  # Exclude news from specific website i.e Yahoo.com and CNN.com
google_news.start_date = (2020, 1, 1) # Search from 1st Jan 2020
google_news.end_date = (2020, 3, 1) # Search until 1st March 2020

The format of the timeframe is a string comprised of a number, followed by a letter representing the time operator. For example 1y would signify 1 year. Full list of operators below:

 - h = hours (eg: 12h)
 - d = days (eg: 7d)
 - m = months (eg: 6m)
 - y = years (eg: 1y)

Setting the start and end dates can be done by passing in either a datetime or a tuple in the form (YYYY, MM, DD).

Supported Countries

print(google_news.AVAILABLE_COUNTRIES)

{'Australia': 'AU', 'Botswana': 'BW', 'Canada ': 'CA', 'Ethiopia': 'ET', 'Ghana': 'GH', 'India ': 'IN',
 'Indonesia': 'ID', 'Ireland': 'IE', 'Israel ': 'IL', 'Kenya': 'KE', 'Latvia': 'LV', 'Malaysia': 'MY', 'Namibia': 'NA',
 'New Zealand': 'NZ', 'Nigeria': 'NG', 'Pakistan': 'PK', 'Philippines': 'PH', 'Singapore': 'SG', 'South Africa': 'ZA',
 'Tanzania': 'TZ', 'Uganda': 'UG', 'United Kingdom': 'GB', 'United States': 'US', 'Zimbabwe': 'ZW',
 'Czech Republic': 'CZ', 'Germany': 'DE', 'Austria': 'AT', 'Switzerland': 'CH', 'Argentina': 'AR', 'Chile': 'CL',
 'Colombia': 'CO', 'Cuba': 'CU', 'Mexico': 'MX', 'Peru': 'PE', 'Venezuela': 'VE', 'Belgium ': 'BE', 'France': 'FR',
 'Morocco': 'MA', 'Senegal': 'SN', 'Italy': 'IT', 'Lithuania': 'LT', 'Hungary': 'HU', 'Netherlands': 'NL',
 'Norway': 'NO', 'Poland': 'PL', 'Brazil': 'BR', 'Portugal': 'PT', 'Romania': 'RO', 'Slovakia': 'SK', 'Slovenia': 'SI',
 'Sweden': 'SE', 'Vietnam': 'VN', 'Turkey': 'TR', 'Greece': 'GR', 'Bulgaria': 'BG', 'Russia': 'RU', 'Ukraine ': 'UA',
 'Serbia': 'RS', 'United Arab Emirates': 'AE', 'Saudi Arabia': 'SA', 'Lebanon': 'LB', 'Egypt': 'EG',
 'Bangladesh': 'BD', 'Thailand': 'TH', 'China': 'CN', 'Taiwan': 'TW', 'Hong Kong': 'HK', 'Japan': 'JP',
 'Republic of Korea': 'KR'}

Supported Languages

print(google_news.AVAILABLE_LANGUAGES)

{'english': 'en', 'indonesian': 'id', 'czech': 'cs', 'german': 'de', 'spanish': 'es-419', 'french': 'fr',
 'italian': 'it', 'latvian': 'lv', 'lithuanian': 'lt', 'hungarian': 'hu', 'dutch': 'nl', 'norwegian': 'no',
 'polish': 'pl', 'portuguese brasil': 'pt-419', 'portuguese portugal': 'pt-150', 'romanian': 'ro', 'slovak': 'sk',
 'slovenian': 'sl', 'swedish': 'sv', 'vietnamese': 'vi', 'turkish': 'tr', 'greek': 'el', 'bulgarian': 'bg',
 'russian': 'ru', 'serbian': 'sr', 'ukrainian': 'uk', 'hebrew': 'he', 'arabic': 'ar', 'marathi': 'mr', 'hindi': 'hi',
 'bengali': 'bn', 'tamil': 'ta', 'telugu': 'te', 'malyalam': 'ml', 'thai': 'th', 'chinese simplified': 'zh-Hans',
 'chinese traditional': 'zh-Hant', 'japanese': 'ja', 'korean': 'ko'}

Article Properties

  • Get news returns a list of articles with the following keys:

RSS backend (default):

FieldDescriptionExample
titleArticle title"Pakistan PM calls for ceasefire"
descriptionShort summary"Pakistan's prime minister said..."
published datePublished date (RFC 2822)"Wed, 07 Jun 2026 07:01:30 GMT"
urlDirect article URL"https://bbc.com/news/..."
publisherPublisher name"BBC News"

SearchApi backend (additional fields):

FieldDescriptionExample
iso_dateISO 8601 publish date"2026-06-07T07:01:30Z"
thumbnailArticle image (base64)"data:image/jpeg;base64,..."
faviconPublisher logo (base64)"data:image/png;base64,..."
rankPosition in search results1

Getting full article

First install the optional dependency:

pip install gnews[fulltext]

Then use get_full_article():

from gnews import GNews

google_news = GNews()
articles = google_news.get_news(‘Pakistan’)
article = google_news.get_full_article(articles[0][‘url’])

print(article[‘text’])   # full article text
print(article[‘url’])    # original URL

Note: Some sites block automated requests (paywalls, Cloudflare). get_full_article() will raise a NetworkError in those cases.

Export Results

Save articles directly to JSON or CSV:

from gnews import GNews

g = GNews(max_results=10)
articles = g.get_news("artificial intelligence")

# Save to JSON
g.save_to_json(articles, "news.json")

# Save to CSV
g.save_to_csv(articles, "news.csv")

Both methods return the output file path. No extra dependencies required.

CLI Usage

GNews includes a command-line interface out of the box:

# Search news
gnews search "artificial intelligence"
gnews search "Pakistan" --lang ur --country PK --max 5

# Top headlines
gnews top
gnews top --max 10

# By topic
gnews topic TECHNOLOGY
gnews topic BUSINESS --max 5

# By site
gnews site bbc.com
gnews site cnn.com --max 3

# By location
gnews location Pakistan
gnews location India --max 5

# JSON output (pipe-friendly)
gnews search "OpenAI" --json
gnews top --json | python3 -m json.tool

Options available on all commands:

OptionDefaultDescription
--langenLanguage code
--countryUSCountry code
--max10Max results
--jsonoffOutput as JSON

Using GNews Behind a Proxy

Google News rate-limits aggressively. If you are pulling more than a few hundred articles, or calling get_full_article() across many domains, you will eventually see HTTP 429s and blocked requests from a single IP.

The fix is to route requests through rotating residential proxies. GNews accepts a standard requests-style proxy dict, so any provider works:

from gnews import GNews

google_news = GNews(
    proxy={
        'http': 'http://YOUR_USERNAME:YOUR_PASSWORD@YOUR_PROXY_HOST:YOUR_PORT',
        'https': 'http://YOUR_USERNAME:YOUR_PASSWORD@YOUR_PROXY_HOST:YOUR_PORT',
    }
)

articles = google_news.get_news('artificial intelligence')

GNews is sponsored by RapidProxy, which is what the maintainer uses for high-volume runs. It offers 90M+ residential IPs, smart rotation, sticky sessions and native static ISP IPs, with traffic that does not expire. Pricing starts at $0.55/GB, and the code RAPID10 gives GNews users 10% off.

from gnews import GNews

RAPIDPROXY = 'http://YOUR_USERNAME:YOUR_PASSWORD@YOUR_PROXY_HOST:YOUR_PORT'

google_news = GNews(
    proxy={'http': RAPIDPROXY, 'https': RAPIDPROXY},
    max_retries=3,
)

articles = google_news.get_news('artificial intelligence')
full = google_news.get_full_article(articles[0]['url'])

Replace YOUR_USERNAME, YOUR_PASSWORD, YOUR_PROXY_HOST and YOUR_PORT with the values generated in your RapidProxy dashboard. Sticky sessions are useful when you want consecutive requests to keep the same exit IP; rotating sessions are better for spreading a large crawl across many IPs.

Tips

  • Keep max_retries at 3 or higher so transient 429s are retried on a fresh IP.
  • Use sticky sessions when fetching an article body, since some sites tie the session to the IP that loaded the page.
  • Residential IPs are slower than datacenter IPs. Increase concurrency rather than expecting each request to be fast.
  • If you would rather skip proxies entirely, the SearchApi backend handles blocking on their side.

SearchApi Integration

GNews supports SearchApi as an optional backend. When a searchapi_key is provided, GNews uses SearchApi instead of the default Google News RSS feed.

Benefits over RSS:

  • Resolved article URLs (fixes broken redirect links, see #62)
  • Pagination beyond the ~100-result RSS cap
  • Richer article data: thumbnail, favicon, iso_date, rank, snippet
  • No IP blocks or rate limits from Google

Setup

pip install gnews

Get a free API key at searchapi.io.

Usage

from gnews import GNews

# Pass your SearchApi key to enable the SearchApi backend
google_news = GNews(searchapi_key="YOUR_SEARCHAPI_KEY")

# All existing methods work as before
articles = google_news.get_news("artificial intelligence")
print(articles[0])
{
  'title': 'OpenAI announces new model',
  'description': 'Article snippet from SearchApi...',
  'published date': '2 hours ago',
  'iso_date': '2026-06-11T10:00:00Z',
  'url': 'https://techcrunch.com/2026/06/11/openai-new-model',
  'publisher': 'TechCrunch',
  'thumbnail': 'data:image/jpeg;base64,...',
  'favicon': 'data:image/png;base64,...',
  'rank': 1
}

Pagination

google_news = GNews(searchapi_key="YOUR_KEY", max_results=50)

# Get page 2 results (breaks past the ~100 RSS cap)
articles = google_news.get_news("Python", page=2)

Additional article fields (SearchApi backend only)

FieldDescription
iso_dateAbsolute ISO 8601 publish date
thumbnailArticle image (base64)
faviconPublisher logo (base64)
rankPosition in search results

The RSS backend (default, no API key required) continues to work exactly as before. The SearchApi backend is fully opt-in.

Async Support

All search methods have async equivalents — no new dependencies required:

import asyncio
from gnews import GNews

g = GNews(max_results=10)

# Single async query
articles = asyncio.run(g.get_news_async("AI"))

# Fetch multiple topics concurrently
async def main():
    ai, python, pakistan = await asyncio.gather(
        g.get_news_async("AI"),
        g.get_news_async("Python"),
        g.get_news_async("Pakistan"),
    )
    return ai, python, pakistan

asyncio.run(main())
Async methodSync equivalent
get_news_async(key, page=1)get_news()
get_top_news_async()get_top_news()
get_news_by_topic_async(topic)get_news_by_topic()
get_news_by_location_async(location)get_news_by_location()
get_news_by_site_async(site)get_news_by_site()

URL Resolution

By default, Google News RSS returns redirect URLs (news.google.com/rss/articles/...) instead of real article URLs. Google requires JavaScript execution to resolve them — plain HTTP requests cannot follow these redirects.

Install the optional Playwright extra to get real article URLs automatically:

pip install gnews[playwright]
playwright install chromium  # one-time setup

Once installed, URL resolution is automatic — no code changes needed:

from gnews import GNews

g = GNews(max_results=5)
articles = g.get_news("AI")

# With gnews[playwright] installed:
print(articles[0]['url'])  # https://www.politico.com/news/...

# Without gnews[playwright]:
print(articles[0]['url'])  # https://news.google.com/rss/articles/...

If resolution fails for a specific article (paywall, timeout, consent gate), GNews falls back to the Google URL silently — it never crashes.

Note: For production use without Playwright, the SearchApi backend always returns real article URLs with zero setup beyond an API key.

gnews-agent (PyPI: gnews-agent) is the sibling package for agents. GNews returns articles. gnews-agent keeps them: it fetches through GNews, deduplicates by title and publisher, embeds the text, and stores it (SQLite + Chroma by default) so later queries are semantic rather than another live search. The same operations — ingest, search, timeline, brief, sentiment, and stats — are available as a Python library, a CLI, and an MCP server for Claude, Cursor, and other clients.

It depends on GNews (gnews>=0.8.2) and installs it for you. ingest, search, timeline, and stats need no API key. brief and sentiment call an LLM.

pip install gnews-agent
from gnews_agent import NewsMemory

memory = NewsMemory()
memory.ingest("OpenAI", method="get_news")
results = memory.search("GPT-5 safety", days=7)
print(results)

Optional extras cover an OpenAI embedding backend (gnews-agent[openai]), full-article text (gnews-agent[fulltext]), and alternate vector stores. The gnews-agent README documents the CLI, the MCP server, and the Claude Code skill. A shorter guide is in these docs: gnews-agent.

Todo

  • Save to MongoDB
  • Save to SQLite
  • Save to JSON ✅
  • Save to .CSV file ✅
  • More than 100 articles ✅
  • Async support ✅
  • Real article URL resolution ✅
  • FastAPI wrapper

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Muhammad Abdullah - @ranahaani - ranahaani@gmail.com

Project Link: https://github.com/ranahaani/GNews

"Buy Me A Coffee"

article
gnews
google-news
google-news-api
google-news-homepage
google-news-rss
google-news-scraper
hacktoberfest
hacktoberfest2025
hacktoberfest-accepted
news
newspaper3k
python
rss-feed

Project health

Overall

4.2/10

Maintained

6/10

Code review

0/10
OpenSSF Scorecard

PyPI

Latest release

0.8.3 · Oct 9, 2026

Releases this year

11

Significant stargazers

Adrien Barbaresi

512 followers · starred Jan 2023

Owen

963 followers · starred Feb 2026

Eshaan Bansal

195 followers · starred May 2021

Achal Jhawar

34 followers · starred Jan 2026