Loading repository data…
Loading repository data…
tashviwadhwa / repository
Command-line tool that ranks news sources by volume, recency, and topic coverage from newsdata.io and writes Plotly leaderboard charts.
A small command-line tool that ranks news sources by how much they publish, how recently, and how many topics they cover. It pulls a batch of recent articles, groups them by source, scores each source, and writes an HTML report with leaderboard charts.
Data comes from the newsdata.io news API (https://newsdata.io). You'll need a free API key to run it.
nextPage cursor across several pages.Requires Python 3.9+.
git clone <your-fork-url>
cd news-source-ranker
pip install -r requirements.txt
Get a free key from https://newsdata.io and export it:
export NEWSDATA_API_KEY=your_key_here
On Windows PowerShell use setx NEWSDATA_API_KEY "your_key_here" and reopen the shell.
python main.py --language en --pages 5 --top 15
Filter the sample with the same parameters the API supports:
python main.py -q "climate" --country us,gb --category environment --top 10 -o climate.html
$ python main.py --language en --pages 4
Fetching articles from newsdata.io /latest ...
# source score vol topics age(h)
--------------------------------------------------------------------
1 Example News Network 100.0 12 18 1
2 Daily Wire Report 74.3 9 11 3
3 Regional Times 61.0 7 9 2
...
Saved report to source_ranking.html
Open source_ranking.html in a browser for the interactive charts.
| Flag | Description |
|---|---|
-q, --query | Search term (q). |
--country | Comma-separated country codes, e.g. us,gb. |
--language | Comma-separated language codes, e.g. en. |
--category | Comma-separated categories, e.g. technology. |
--pages | Number of API pages to pull (about 10 articles each). Default 5. |
--top | How many sources to chart. Default 15. |
-o, --output | Output HTML path. Default source_ranking.html. |
Each signal is min–max scaled to 0–100 across the sources in the current sample,
then combined: score = 0.5*volume + 0.3*recency + 0.2*coverage. Because the
scaling is relative to the sample, scores describe a source's standing within
this run, not an absolute rating. Pull more pages for a steadier picture.
The default run uses only free-tier endpoints and parameters. A couple of extras are wired up but off by default because they need a paid newsdata.io plan:
--archive (with --from-date / --to-date) queries the historical
/archive endpoint instead of /latest.sentiment is read straight from the response when present and
shown in the sentiment chart. On a free key that field is absent, so the chart
falls back to clearly labeled sample values.If a request that uses a paid parameter is rejected, the client drops those
parameters and retries once, so you still get free-tier results. The keywords
field used for topic coverage is available on the free tier.
NEWSDATA_API_KEY; it is never written to disk.MIT