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.
Release files for google-news-feed 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| google_news_feed-1.1.0.tar.gz | 7.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| google_news_feed-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.9 kB
Release files / google_news_feed-1.1.0.tar.gz
| Download URL | google_news_feed-1.1.0.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7d410faa62b019ec3ba02d50afe202432275c2f02d6bf30d53611cd9510fa415
|
|
BLAKE2b-256 checksum How to use checksums |
251ae688e45aaab206b70547d8d8864a4e8382ed14854998941d6ba85ac16072
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / google_news_feed-1.1.0-py3-none-any.whl
| Download URL | google_news_feed-1.1.0-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
add53b554b7f65a9d07936b714527e9711d30ec1bd3f903e611ba69ad8ec3add
|
|
BLAKE2b-256 checksum How to use checksums |
c5fc4780664bcfaf258a89357947e86cbe8c261c247be40463a248412c273e45
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|