How To Get News Instantly From Commandline In Linux
In this Digital era, there are plethora of apps and utilities available to read news from online. Most of them are GUI-based. Fortunately, there is a command line utility to read News for those who live in Terminal all day. Meet “Instantnews” – a simple, yet useful CLI utility to get news from commandline. This utility instantly retrieves all sorts of news and displays them in the Terminal. So, you don’t need any GUI applications or don’t leave from Terminal or don’t even need hard copies to read World news. In this brief tutorial, I will explain how to install “instantnews” and how to get world news right from the Terminal in Unix-like operating systems.
Instantnews – Get News Instantly From Commandline In Linux
The Instantnews utility can be installed either using pip or can directly be compiled and installed from source.
Install Instantnews Using PIP
First, install pip as shown below.
On Arch Linux and its derivatives, run the following command to install pip:
$ sudo pacman -S python-pip
On Debian, Ubuntu, Linux Mint:
$ sudo apt-get install python-pip
On RHEL, Fedora, CentOS:
$ sudo yum install python-pip
$ sudo dnf install python-pip
$ sudo zypper install python-pip
Once pip installed, install Instantnews using pip with command:
$ pip install instantnews
Install Instantnews from source
To build from source, do the following:
$ git clone https://github.com/shivam043/instantnews.git $ cd instantnew $ sudo python setup.py install
Instantnews retrieves all news headlines from News API. For those wondering, News API is a simple and easy-to-use API that returns JSON metadata for the headlines currently published on a range of news sources and blogs. It currently provides live headlines from 70 popular sources, including Ars Technica, BBC, Blooberg, CNN, Daily Mail, Engadget, ESPN, Financial Times, Google News, hacker News, IGN, Mashable, National Geographic, Reddit r/all, Reuters, Speigel Online, Techcrunch, The Guardian, The Hindu, The Huffington Post, The Newyork Times, The Next Web, The Wall street Journal, USA today and more.
First, you need an API key from News API. Go to https://newsapi.org/register URL and register a free account to get the API key.
Once you got the API key from News API site, edit your .bashrc file:
$ vi ~/.bashrc
Add newsapi API key at the end like below:
Please note that you need to paste the key inside the double quotes. Save and close the file.
Run the following command to update the changes.
$ source ~/.bashrc
To display help, run:
$ instantnews -h usage: instantnews [-h] [--show SHOW] [--show_all] [--news NEWS] optional arguments: -h, --help show this help message and exit --show SHOW, -s SHOW Shows all the news channel codes category wise --show_all, -sa Shows all the news channel codes --news NEWS, -n NEWS Shows news
List all available news channels
Let us see the list of all available news channels.
$ instantnews -sa
$ instantnews --show_all
Sample output would be:
News Code: <abc-news-au> ABC News (AU) News Code: <al-jazeera-english> Al Jazeera English News Code: <ars-technica> Ars Technica News Code: <associated-press> Associated Press News Code: <bbc-news> BBC News News Code: <bbc-sport> BBC Sport News Code: <bild> Bild News Code: <bloomberg> Bloomberg News Code: <breitbart-news> Breitbart News News Code: <business-insider> Business Insider News Code: <business-insider-uk> Business Insider (UK) News Code: <buzzfeed> Buzzfeed News Code: <cnbc> CNBC News Code: <cnn> CNN News Code: <daily-mail> Daily Mail News Code: <der-tagesspiegel> Der Tagesspiegel News Code: <die-zeit> Die Zeit News Code: <engadget> Engadget News Code: <entertainment-weekly> Entertainment Weekly News Code: <espn> ESPN News Code: <espn-cric-info> ESPN Cric Info News Code: <financial-times> Financial Times News Code: <focus> Focus News Code: <football-italia> Football Italia News Code: <fortune> Fortune News Code: <four-four-two> FourFourTwo News Code: <fox-sports> Fox Sports News Code: <google-news> Google News News Code: <gruenderszene> Gruenderszene News Code: <hacker-news> Hacker News News Code: <handelsblatt> Handelsblatt News Code: <ign> IGN News Code: <independent> Independent News Code: <mashable> Mashable News Code: <metro> Metro News Code: <mirror> Mirror News Code: <mtv-news> MTV News News Code: <mtv-news-uk> MTV News (UK) News Code: <national-geographic> National Geographic News Code: <new-scientist> New Scientist News Code: <newsweek> Newsweek News Code: <new-york-magazine> New York Magazine News Code: <nfl-news> NFL News News Code: <polygon> Polygon News Code: <recode> Recode News Code: <reddit-r-all> Reddit /r/all News Code: <reuters> Reuters News Code: <spiegel-online> Spiegel Online News Code: <t3n> T3n News Code: <talksport> TalkSport News Code: <techcrunch> TechCrunch News Code: <techradar> TechRadar News Code: <the-economist> The Economist News Code: <the-guardian-au> The Guardian (AU) News Code: <the-guardian-uk> The Guardian (UK) News Code: <the-hindu> The Hindu News Code: <the-huffington-post> The Huffington Post News Code: <the-lad-bible> The Lad Bible News Code: <the-new-york-times> The New York Times News Code: <the-next-web> The Next Web News Code: <the-sport-bible> The Sport Bible News Code: <the-telegraph> The Telegraph News Code: <the-times-of-india> The Times of India News Code: <the-verge> The Verge News Code: <the-wall-street-journal> The Wall Street Journal News Code: <the-washington-post> The Washington Post News Code: <time> Time News Code: <usa-today> USA Today News Code: <wired-de> Wired.de News Code: <wirtschafts-woche> Wirtschafts Woche
Like I mentioned already, there are 70 news sources as of writing this guide. More will be added in the days to come. As you see in the above output, all news codes are listed in a single output. You can also display news channels category wise.
List news channels category wise
To display all the news channel codes category wise, run:
$ instantnews --show SHOW <category>
$ instantnews -s SHOW <category>
The following categories are available.
Now, to display news channels category wise, say technology, run:
$ instantnews --show technology
$ instantnews -s technology
Sample output would be:
News Code: <ars-technica> Ars Technica News Code: <engadget> Engadget News Code: <gruenderszene> Gruenderszene News Code: <hacker-news> Hacker News News Code: <recode> Recode News Code: <t3n> T3n News Code: <techcrunch> TechCrunch News Code: <techradar> TechRadar News Code: <the-next-web> The Next Web News Code: <the-verge> The Verge News Code: <wired-de> Wired.de
Get news instantly from Terminal
To get news headlines from a news channel, say The Hindu, run the following command with correct News code:
$ instantnews --news the-hindu
$ instantnews -n the-hindu
Now, you will see all news headlines from the given news source i.e The Hindu in our case.
Similarly, you can read news any other sources. For example, to read news headlines from Techcrunch, run the following command:
$ instantnews -n techcrunch
While testing it, I noticed that I can’t open any particular news code in my web browser to read more about it. I guess it’s a bug. Of course, there is no code without bugs. Hope the developer will fix it and add some new features. This project is very new and is being actively developed. If there are any bugs or feature requests, notify them in the GitHub page given at the end.
And, that’s all for today folks. Hope this helps. I will be soon here with another interesting topic. Till then, stay tuned with OSTechNix!
Thanks for stopping by!
Help us to help you:
- Subscribe to our Email Newsletter : Sign Up Now
- Support OSTechNix : Donate Via PayPal
- Download free E-Books and Videos : OSTechNix on TradePub
- Connect with us: Facebook | Twitter | Google Plus | LinkedIn | RSS feeds
Have a Good day!!