Wikipedia:Scripts/mwlink

This Ruby program has two modes. It can run as a daemon or text processor (daemon mode is preferred, since it's more efficient).

In text-scanning mode, it interprets its command line (or stdin if no command line given) as text possibly containing wikilinks. It preserves the original text and adds a text hyperlink (the http: address contained in &lt;&gt; braces).

In daemon mode, it receives HTTP requests like http://localhost:4242/mwlink?page=wiki-page-name and redirects to the appropriate Wikimedia page. It's convenient for scripts to just use that URL rather than constructing one themselves--all they have to do is URL-escape the text between and.

Example output:

Ashland (disambiguation) is an example of a Disambiguation page.

Ashland (disambiguation)  is an example of a Disambiguation  page.

GET http://localhost:4242/mwlink?page=Ashland+%28disambiguation%29

GET http://localhost:4242/mwlink?page=Ashland+%28disambiguation%29 --> 302 Found GET http://en.wikipedia.org/wiki/Ashland_%28disambiguation%29 --> ...(page content)

The GET program is a utility distributed with Perl's libwww. Also, note that wikimedia servers forbid scripts based on the LWP Perl module.