Skip to content

Instantly share code, notes, and snippets.

@DiegoPinho
Created April 28, 2018 03:55
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 DiegoPinho/49d6c04af85266f88b1be849dd6cb787 to your computer and use it in GitHub Desktop.
Save DiegoPinho/49d6c04af85266f88b1be849dd6cb787 to your computer and use it in GitHub Desktop.
function searchForTermOnWikipedia(term) {
// example: https://en.wikipedia.org/w/api.php?action=opensearch&search=zyz&limit=1&namespace=0&format=jsonfm
var action = 'action=opensearch';
var search = 'search=' + term;
var format = 'json';
var params = '?' + action + '&' + search + '&' + format + '&callback=?';
var url = WIKIPEDIA_API_URL + params;
$.getJSON(url, function(data) {
// faz algo com o resultado...
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment