Help Wikitravel grow by contributing to an article! Learn how.

User:Jpatokal/StatScript

From Wikitravel
Jump to: navigation, search

StatScript's miserable lot in life is to keep Wikitravel:Multilingual statistics up to date without too much manual labor on my part.

Script[edit]

Written in luvvly-jubbly awk, also requires wget. Now uses Mediawiki's internal raw statistics.

BEGIN {
  LIST="en fr ro de sv ja nl pt es pl it"

  split(LIST, list)
  for(i in list) {
    #print list[i]
    cmd = "wget -O " list[i] " 'http://wikitravel.org/wiki/" list[i] "/index.php?title=Special:Statistics&action=raw'; sleep 3"
    system(cmd) 
    ARGV[i]=list[i]
    n++
  }
  ARGC=++n
}
 
/total=/ { split($0, fields, ";")
           split(fields[2], values, "=")
           num[j++]=values[2]
           total+=values[2] }

END {
  CONVFMT="%.2f"
  print "|-"
  printf "| " strftime("%d %b %Y") " "
  for (i=0;i<j;i++) {
    printf "|| " num[i] " (" (100*num[i])/total "%) "
  }
  printf "|| " total
}

Output[edit]

|-
| 06 Jul 2006 || 9872 (61.76%) || 1151 (7.20%) || 482 (3.02%) || 2382 (14.90%) || 376 (2.35%) || 857 (5.36%) || 115 (0.72%) || 200 (1.25%) || 294 (1.84%) || 63 (0.39%) || 193 (1.21%) || 15985

Variants

Actions

Destination Docents

In other languages