Skip to content

Instantly share code, notes, and snippets.

@kubido
Created November 1, 2011 03:29
Show Gist options
  • Save kubido/1329804 to your computer and use it in GitHub Desktop.
Save kubido/1329804 to your computer and use it in GitHub Desktop.
scrap indonesia province data list from wikipedia, for seed data
// url : http://id.wikipedia.org/wiki/Daftar_provinsi_Indonesia
arr = new Array();
// random id from 0 - 5
random_country_id = Math.floor(Math.random() * (5 - 1 + 1) + 1);
$('.wikitable.sortable.jquery-tablesorter tr').each(function(i, tr){
td = $(tr).children()[2]
name = $(td).text();
if(i < 11){
i = "0"+i
}
string = 'province_'+i+':<br/>&nbsp; name: "'+ name +'"<br/>&nbsp; country_id: random_country_id<br/><br/>';
arr.push(string);
$('body').html(arr.join(" "))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment