Skip to content

Instantly share code, notes, and snippets.

@hubgit
Created May 26, 2015 00:28
Show Gist options
  • Save hubgit/90fd36028dc2b608480a to your computer and use it in GitHub Desktop.
Save hubgit/90fd36028dc2b608480a to your computer and use it in GitHub Desktop.
Fetch the HTML of a Wikipedia page's infobox
$.ajax({
dataType: 'jsonp', // no CORS
url: 'https://en.wikipedia.org/w/api.php',
data: {
action: 'query',
prop: 'revisions',
rvprop: 'content',
format: 'json',
rvsection: '0', // infobox
rvparse: '', // convert to HTML
redirects: '', // follow title redirects
titles: title
},
success: function(data) {
var keys = Object.keys(data.query.pages);
var content = data.query.pages[keys[0]].revisions[0]['*'];
var data = $('.infobox', content).get(0);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment