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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file google_news_feed-1.1.0.tar.gz.
File metadata
- Download URL: google_news_feed-1.1.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d410faa62b019ec3ba02d50afe202432275c2f02d6bf30d53611cd9510fa415
|
|
| MD5 |
c4085e7191e02877bba05cf62b1a4bf1
|
|
| BLAKE2b-256 |
251ae688e45aaab206b70547d8d8864a4e8382ed14854998941d6ba85ac16072
|
File details
Details for the file google_news_feed-1.1.0-py3-none-any.whl.
File metadata
- Download URL: google_news_feed-1.1.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
add53b554b7f65a9d07936b714527e9711d30ec1bd3f903e611ba69ad8ec3add
|
|
| MD5 |
d91006c15a1cfbac483b1e6284699ae2
|
|
| BLAKE2b-256 |
c5fc4780664bcfaf258a89357947e86cbe8c261c247be40463a248412c273e45
|