User:Demi/wikitext

This is a bash function that prints the wikitext of an article. For example, "wikitext 'Lithia Park'". It's not very robust but it works a lot of the time. You can use it to do a word count by doing something like "wikitext 'Lithia Park' | wc -w". Sorry for the wide page.

wikitext {  ruby -r'rexml/document' -rcgi -rtempfile -ropen-uri \ -e "u = 'http://en.wikipedia.org/wiki/Special:Export/' + CGI::escape(ARGV[0].strip.squeeze(' ').tr(' ', '_')).gsub(/%3[Aa]/,':').gsub(/%2[Ff]/,'/').gsub(/%23/,'#'); open(u) { |f| puts REXML::XPath.first(REXML::Document::new(f.class == Tempfile ? f.open : f), '//text').text }" \ "$*" }