Skip to main content

A simple python library to consume the google news rss feed

Project description

Google-News-Feed

A simple python library to consume the google news rss feed.

Inspired by pygooglenews and implemented using aiohttp and lxml.

Installation

Via pip: pip install google-news-feed

How to use

from google_news_feed import GoogleNewsFeed

gnf = GoogleNewsFeed(language='en',country='US')
results = gnf.query("python")
print(results)

For more information about the query parameters see here.

Get Top Headlines

gnf = GoogleNewsFeed(language='en',country='US')
results = gnf.top_headlines()

Query a specific topic

gnf = GoogleNewsFeed(language='en',country='US')
results = gnf.query_topic("business")

For more topics see here.

Accessing the results

The results are a list of NewsItems.

result = gnf.query("python")[0]
print(result.title)
print(result.link)
print(result.pubDate)
print(result.description)
print(result.source)

Handling internal links

Some links are internal to google news. To access the actual link to the news site the internal link has to be accessed and the redirect url is returned. To simplify this process the resolve_internal_links property can be set to True.

gnf = GoogleNewsFeed(language='en',country='US',resolve_internal_links=True)
print(gnf.top_headlines()[0].link)

The resolution is handled asynchronously by default, but can be forced to be done synchronously via the run_async parameter.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

google_news_feed-1.1.0.tar.gz (7.1 kB view hashes)

Uploaded Source

Built Distribution

google_news_feed-1.1.0-py3-none-any.whl (5.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page