Created
May 26, 2015 00:28
-
-
Save hubgit/90fd36028dc2b608480a to your computer and use it in GitHub Desktop.
Fetch the HTML of a Wikipedia page's infobox
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
$.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