CLI Usage

GNews includes a command-line interface available after pip install gnews.

Commands

top

gnews top
gnews top --max 20 --json

topic

gnews topic TECHNOLOGY
gnews topic BUSINESS --max 10 --json

site

gnews site bbc.com
gnews site cnn.com --max 5 --json

location

gnews location Pakistan
gnews location "New York" --json

Common options

Option

Default

Description

--lang

en

Language code

--country

US

Country code

--max

10

Max results

--json

off

Output as JSON

JSON output

The --json flag outputs valid JSON to stdout, making it easy to pipe into other tools:

gnews search "AI" --json | python3 -m json.tool
gnews top --json | jq '.[0].title'