2

I'm wondering if there is any command to fetch the "introduction" (and perhaps the full article) of a Wikipedia entry on a terminal.

I found this article and a lot of article redirecting to it, but unfortunately when running this in the console it gives:

$ dig +short txt fooba.wp.dg.cx
$

It exits with code 0 so no error, but it doesn't show anything either.

Are there any Wikipedia query commands for Linux. I use lynx to browse the Internet, but sometimes you simply want to fetch the introduction fast and do some processing on it.

Serge Stroobandt
  • 4,838
  • 1
  • 45
  • 58
Willem Van Onsem
  • 618
  • 1
  • 8
  • 18
  • That is pretty interesting way of doing it, but it's just a proof of concept, not actually used. Not to mention that your question has little to do with Ubuntu. – Marek Bettman Sep 17 '15 at 23:26
  • @MarekBettman: Well I'm still using ubuntu as the operating system. This has not (much) to do with programming so SO is not the correct place either,... Feel free to move this to another SE. – Willem Van Onsem Sep 17 '15 at 23:28
  • Why can't you just pipe the output of `lynx` to your text-processing tool, via `lynx -dump`? – muru Sep 17 '15 at 23:30
  • @muru: The problem is that wikipedia attaches some noise around the article (like search bar,...) – Willem Van Onsem Sep 17 '15 at 23:31
  • @MarekBettman the OP is asking how to do something on Ubuntu. That's 100% on topic here. Also see relevant discussion here: [Asking questions about third-party applications running on Ubuntu](http://meta.askubuntu.com/q/14382) – terdon Sep 18 '15 at 15:25

2 Answers2

4

Well, looking around:

$ apt search wikipedia              
Sorting... Done
Full Text Search... Done
libwww-wikipedia-perl/trusty 2.00-1 all
  perl module that provides an automated interface to Wikipedia

wikipedia2text/trusty,now 0.11-3 all [installed]
  displays Wikipedia articles on the command line

wikipediafs/trusty 0.4-5 all
  View and edit Wikipedia articles as if they were real files

Looking at the manpage of wikepedia2text:

-s        Display only the summary of the Wikipedia article.

-S        Display the full content of the  Wikipedia  article  and  not
          only the summary.

Testing it out:

$ wikipedia2text -s Linux
Changes must be reviewed before being displayed on this page.show/hide details
This is the latest accepted revision, reviewed on 17 September 2015.
Jump to: navigation, search
This article is about the operating system. For the kernel (also often referred
to as just "Linux"), used in all variants of the Linux operating system, see
Linux kernel. For other uses, see Linux (disambiguation).

                                     Linux
Tux the penguin
Tux the penguin, mascot of Linux^
Developer Community
 Written  Primarily C and assembly
   in
OS family Unix-like
 Working  Current
  state
 Source   Mainly open source, proprietary software also available


$ wikipedia2text Linux   
Page protected with pending changes level 1

Linux

From Wikipedia, the free encyclopedia
Changes must be reviewed before being displayed on this page.show/hide details
This is the latest accepted revision, reviewed on 17 September 2015.
Jump to: navigation, search
This article is about the operating system. For the kernel (also often referred
to as just "Linux"), used in all variants of the Linux operating system, see
Linux kernel. For other uses, see Linux (disambiguation).

                                     Linux
Tux the penguin
Tux the penguin, mascot of Linux^
Developer Community
 Written  Primarily C and assembly
   in
OS family Unix-like
 Working  Current
  state
 Source   Mainly open source, proprietary software also available
  model
 Initial  1991; 24 years ago (1991)
 release
Marketing Personal computers, mobile devices, embedded devices, servers,
 target   mainframes, supercomputers
Available Multilingual
   in
          Alpha, ARC, ARM, AVR32, Blackfin, C6x, ETRAX CRIS, FR-V, H8/300,
Platforms Hexagon, Itanium, M32R, m68k, META, Microblaze, MIPS, MN103, Nios II,
          OpenRISC, PA-RISC, PowerPC, s390, S+core, SuperH, SPARC, TILE64,
          Unicore32, x86, Xtensa
 Kernel   Monolithic (Linux kernel)
  type
Userland  Various
Default
  user    Many
interface
 License  GPLv2^ and other free and open-source licenses, except for the
          "Linux" trademark^[a]

...
muru
  • 193,181
  • 53
  • 473
  • 722
  • Unfortunately, `wikipedia2text` is currently quite crippled in Ubuntu LTS 18.04. One needs to specify a browser in order to circumvent a [` not found` bug](https://github.com/chrisbra/wikipedia2text/issues/4). – Serge Stroobandt Jan 28 '19 at 20:40
0

Its possible to download wikipedia articles via their gopherized versions.

Here is an example pulling the article on sed:

lynx -dump gopher://gopherpedia.com/0/sed | less -  

Also if the article needs to be searched for go to the main page:

lynx gopher://gopherpedia.com/1

Or directly to the search:

lynx gopher://gopherpedia.com/7/lookup 
DC Slagel
  • 109
  • 1
  • 6