{"id":23798,"library":"gnews","title":"GNews","description":"A lightweight Python client to search and retrieve news articles from Google News, returning structured JSON. Current version 0.4.3. Low release cadence, last release in 2021.","status":"active","version":"0.4.3","language":"python","source_language":"en","source_url":"https://github.com/ranahaani/GNews","tags":["news","google-news","api","scraper"],"install":[{"cmd":"pip install gnews","lang":"bash","label":"latest release"}],"dependencies":[{"reason":"HTTP requests to Google News","package":"requests","optional":false},{"reason":"HTML parsing","package":"beautifulsoup4","optional":false}],"imports":[{"note":"Correct class name is GNEWS (uppercase)","wrong":"from gnews import Gnews","symbol":"GNEWS","correct":"from gnews import GNEWS"},{"note":"No such submodule","wrong":"from gnews_client import GNEWS","symbol":"GNEWS","correct":"from gnews import GNEWS"},{"note":"gnews module doesn't export the class directly at module level","wrong":"import gnews","symbol":"GNEWS","correct":"from gnews import GNEWS"}],"quickstart":{"code":"from gnews import GNEWS\n\n# Initialize with optional language and country\ngnews = GNEWS(language='en', country='US')\n\n# Search for news\nresults = gnews.get_news('Python programming')\nfor article in results[:3]:\n    print(article['title'], '-', article['url'])","lang":"python","description":"Basic usage: create a GNEWS instance and call get_news() to retrieve articles."},"warnings":[{"fix":"Update code to handle list directly, not accessing .get('entries').","message":"Version 0.2.3 changed the method signature. `GNEWS.get_news(query)` now returns a list of dicts instead of a dict with 'entries' key.","severity":"breaking","affected_versions":">=0.2.3"},{"fix":"Use `from gnews import GNEWS`.","message":"The class name is `GNEWS` (all caps), not `Gnews` or `GNews`. Many examples online use incorrect casing.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `get_news(query)` with appropriate keywords instead.","message":"The `get_news_by_topic` method is no longer documented and may be removed in future versions.","severity":"deprecated","affected_versions":">=0.2.3"},{"fix":"Manually set headers on the session: `gnews.session.headers.update({'User-Agent': 'Mozilla/5.0 ...'})`.","message":"Google News may block requests without proper User-Agent. The library does not set one by default.","severity":"gotcha","affected_versions":"all"},{"fix":"Use valid country codes. Common ones: 'US', 'GB', 'IN', 'CA'.","message":"The `country` parameter in constructor expects ISO 3166-1 alpha-2 code (e.g., 'US', 'IN'). Wrong codes may silently return empty results.","severity":"breaking","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `pip install gnews` and use `from gnews import GNEWS`.","cause":"Package not installed or wrong import path.","error":"ModuleNotFoundError: No module named 'gnews'"},{"fix":"Ensure you installed the correct package: `pip uninstall gnews` then `pip install gnews`. Then import with `from gnews import GNEWS`.","cause":"Possibly a different library with same name, or incorrect import statement.","error":"AttributeError: module 'gnews' has no attribute 'GNEWS'"},{"fix":"Check network connectivity and handle None: `results = gnews.get_news('query') or []`.","cause":"`get_news()` returned None due to network error or empty search results.","error":"TypeError: 'NoneType' object is not iterable"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}