开发者

Get pages from MediaWiki API using jQuery

开发者 https://www.devze.com 2023-03-03 13:12 出处:网络
I\'ve been trying to come up with a solution to get links/pages (dunno what it\'s called) from a MediaWiki category page using simple jQuery. I\'m been reading the API docs but don\'t really know what

I've been trying to come up with a solution to get links/pages (dunno what it's called) from a MediaWiki category page using simple jQuery. I'm been reading the API docs but don't really know what to look for.

If you look at this page you'll see release dates for video games.. that's the information I want to obtain. And this is as far as I got:

var title="Upcoming_video_games";

$.getJSON("http://en.wikipedia.org/w/api.php?action=query&list=allpages&titles="+title+"&format=json&callback=?", function(data) {
    console.log(data);
});

Does someone know how to do this? Any help is appreci开发者_开发问答ated.

TIA


Try this

var url = "http://en.wikipedia.org/w/api.php?action=parse&format=json&callback=?";
var page = "Pune"; // your page title, eg. New_York

$.getJSON(url, { 
  page: page, 
  limit:1,
  prop:"text|images", 
  uselang:"en"
}, function(data) {
  var $container = $("body")

  // append body
  //$container.append(data['parse']['text']['*']); 

Then get data in var and use find function each object like images, title, or some tags.. Abhijeet...

0

精彩评论

暂无评论...
验证码 换一张
取 消