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

Difference between revisions of "User:IBobi/StatScript"

From Wikitravel
Jump to: navigation, search
(Created page with "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] ...")
 
 
Line 1: Line 1:
 +
==Script==
 +
Written in luvvly-jubbly [http://www.gnu.org/software/gawk/manual/gawk.html awk], also requires [http://www.gnu.org/software/wget/wget.html wget].  Now uses Mediawiki's internal raw statistics.
 +
 +
<pre><nowiki>
 
BEGIN {
 
BEGIN {
 
   LIST="en fr ro de sv ja nl pt es pl it"
 
   LIST="en fr ro de sv ja nl pt es pl it"
Line 27: Line 31:
 
   printf "|| " total
 
   printf "|| " total
 
}
 
}
 +
</nowiki></pre>

Latest revision as of 19:32, 11 January 2013

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
}

Variants

Actions

Destination Docents

In other languages