Skip to content

Instantly share code, notes, and snippets.

@toocool
Created December 23, 2016 12:42
Show Gist options
  • Save toocool/2c9a8c9c77c7dd31f5e668234b87d854 to your computer and use it in GitHub Desktop.
Save toocool/2c9a8c9c77c7dd31f5e668234b87d854 to your computer and use it in GitHub Desktop.
get info from wikipedia
<script>
function dowiki(place) {
var URL = 'https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro=&explaintext=';
URL += "&titles=" + place;
URL += "&rvprop=content";
URL += "&callback=?";
$.getJSON(URL, function (data) {
var obj = data.query.pages;
var ob = Object.keys(obj)[0];
console.log(obj[ob]["extract"]);
try{
document.getElementById('Label11').textContent = obj[ob]["extract"];
}
catch (err) {
document.getElementById('Label11').textContent = err.message;
}
});
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment