Source: site.view [edit]
Function name: countryInfo
Arguments: country
Description: Returns 2 and 3 letter country codes, phone code, and population
Page type: webl
Render function:  
Module: global

Page source:

var P = GetURL("http://countrycode.org") ? nil;

var clean = fun(e) 
   var s = Text(e);
   s = Wub_ReplaceAll(s, ` `, " ");
   s = Str_Trim(s);
   s;
end;

var info = [. .];

if (P != nil) then

   var Rows = Elem(P, "tr") contain Pat(P, country);
   if Size(Rows) == 1 then
      var Cols = Elem(P, "td") inside Rows[0];
      if Size(Cols) > 3  then
         info.name := clean(Cols[0]);
         var CC = Str_Split(clean(Cols[1]), "/");
         info.code2 := Str_Trim(CC[0]);
         info.code3 := Str_Trim(CC[1]);
         info.phoneCode := clean(Cols[2]);
         info.population := clean(Cols[3]);
      end;
   end
end;

info;