Skip to content

Instantly share code, notes, and snippets.

@antpaw
Last active April 3, 2019 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antpaw/236959d69adce44a816e700f7d802bb2 to your computer and use it in GitHub Desktop.
Save antpaw/236959d69adce44a816e700f7d802bb2 to your computer and use it in GitHub Desktop.
Get Country ISO codes with translated names
// https://laendercode.net/de/2-letter-list.html
var table = document.querySelectorAll('.table')[0]
var codes = [].slice.call(table.querySelectorAll("h4")).map(function(elem) { return elem.innerText; })
var names = [].slice.call(table.querySelectorAll("td:last-child a")).map(function(elem) { return elem.innerText; })
var object = codes.map(function(code, i) { return {code, name: names[i]}; })
var elem = document.createElement("textarea");
elem.cols = "100";
elem.rows = "800";
elem.value = JSON.stringify(object, null, 2);
document.body.appendChild(elem);
elem.focus();
elem.select();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment