A zero-dependency Python command-line interface (CLI) to fetch, search, filter, and view the latest news headlines from Google News right inside your terminal.
- No external dependencies: Built entirely using Python's standard library (
urllib,xml.etree.ElementTree, etc.). - Interactive Mode: Browse headlines, search for terms, filter by predefined topics, refresh feeds, and open articles directly in your system's default web browser.
- CLI Options: Run quick queries, specify topics, limit the number of articles displayed, and choose custom regions/languages.
- Visual formatting: Colorized terminal output using ANSI escape sequences.
Make the script executable:
chmod +x gnews.pyRun the script without any parameters to enter interactive mode with the top headlines:
./gnews.pyOr run with python3:
python3 gnews.pySearch for a specific query and exit:
python3 gnews.py --search "artificial intelligence"Filter headlines by topic (e.g., world, nation, business, tech, sports, science, health):
python3 gnews.py --topic technologySpecify the number of articles to return (default is 10):
python3 gnews.py --limit 5Force interactive mode after performing a query or topic filter:
python3 gnews.py --search "space" --interactiveCustomize the language and region using standard two-letter codes:
python3 gnews.py --gl US --lang enOnce in the interactive menu:
[1-N]: Enter the number of an article to open its URL in your default browser.s: Prompt for a new search query.t: List available topics and switch to a selected topic feed.r: Refresh the current view.q: Quit the application.