Last active
April 3, 2019 08:29
-
-
Save antpaw/236959d69adce44a816e700f7d802bb2 to your computer and use it in GitHub Desktop.
Get Country ISO codes with translated names
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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