Skip to content
Theodor A. Dumitrescu edited this page Jan 29, 2018 · 6 revisions

wtf.from_api

wtf.from_api("<page's-name>", "<wiki-site-code>", function(markup){ 
               //markup is the raw contents of the wiki's page searched
               //call the function wtf.parse to parse the markup
               //it will return an obj that contain all the data from the page
	       var site_parsed = wtf.parse(markup); 
});

import wiki' sites code

  • itwikiversity := wikiversity in italian
  • enwikiversity := wikiversity in inglish
  • itwiki := wikipedia in italian
  • enwiki := wikipedia in english

all the other ids can be found here

wtf.parse

The parse function return a JSON that contains all the information from the page. The sections are stored into an ordered array "nodeDataArray". Each section as an attribute "depth" that contain the level of depth into the tree structure of the page. The tree structure is stored into nodeDataArray using a the Pre-order pattern for traversing. For example considering the following array [ {text:"A", depth:0}, {text:"B", depth:1}, {text:"D", depth:2}, {text:"C", depth:1}, {text:"E", depth:2}, {text:"F", depth:3}], we can understand that A is the root since A's depth is 0. Because B, and C have depth equal to 1, they are A's children. Than D is the child of B, E is the child of C, and F is child of E. This also means that A is the main section, B is an sub-section of A, D is a sub-section of B and so on.

Clone this wiki locally