In the next article we are going to take a look at Wikipedia2text. This is a small shell script that will allow us to consult Wikipedia articles from the console. With it we can also open the selected article in any text browser. It is an application similar to Wiki, which is an application to search Wikipedia from the terminal for articles and summaries, about which we have already published an article in this same blog.
Most of us sooner or later pull up Wikipedia. Either to find information about any company or other information about almost anything that comes to mind or needs to consult. When we do a search in google, by default the link to Wikipedia is usually in the Top 5. Wikipedia has about 40 million articles, approximately in more than 299 different languages. To say that the English Wikipedia is the largest version.
This shell script use a text browser to consult and represent Wikipedia articles. The output will be printed as standard output. Is currently supports about 30 Wikipedia languages.
As I said, this script uses the text browser to query and render Wikipedia articles. Thus we will need to install any of the following text mode browsers. Then we can continue with the installation of Wikipedia2text. As long as we do not install a browser for the terminal, it will not allow us to make inquiries.
How to install Wikipedia2text on Ubuntu
On Debian-based distributions this package is included in the default repository. However, we will also be able to install it in other distributions.
In Debian, Ubuntu and derivatives, we can install this script using package manager. We open a terminal (Ctrl + Alt + T) and we will only have to write the following command:
sudo apt install wikipedia2text
Although if we do not want to install anything we will also have the option to clone repository and move Wikipedia2text file only to / bin directory. We can leave it with the same name or if you want to make it shorter and easier to remember, rename it as wikicli (or another name of your liking), as I am going to do in the following example. To do this, we open a terminal (Ctrl + Alt + T) and write each of the following commands:
git clone https://github.com/chrisbra/wikipedia2text sudo mv wikipedia2text/wikipedia2text /bin/wiki-cli rm -Rf wikipedia2text/
How to use Wikipedia2text
See Wikipedia2text help
When we launch the command without any argument, by default we will be shown the help page of the tool. In it we will be able to consult all the options that we will find available to use when launching the script.
Among them I want to highlight the one that will allow us check supported languages. As you can see in the previous screenshot, it will show us the acronyms that we can use when consulting the articles in different languages.
To launch this script and consult the help, we will only have to open a terminal (Ctrl + Alt + T) and type:
wiki-cli
Read Article
To read any Wikipedia article, run the following command. You will have to press the space bar to advance to the next page from the article:
wiki-cli -p ubuntu
Read article in another language
We will be able to read the article in other languages supported by Wikipedia, which I already mentioned lines above. Actually the script supports 30 languages. To do this, run the following command. In this example we are going to test the French language:
wiki-cli -pl fr arch linux
Open an article in the text browser
To open the Wikipedia article at the text browser that we will have to have previously installed, run the following command:
wiki-cli -po opensuse
Get the URL of an article
In case you want know the URL of the query, you can obtain this information by executing the following command:
wiki-cli -u debian
Uninstall Wikipedia2text
In the event that we use apt to install this script on our computer, we can easily remove it as we always do. We open the terminal (Ctrl + Alt + T) and write the following command in it:
sudo apt remove wikipedia2text
If we want to take a look at the source code of this utility, we can see it in the project GitHub page.