Reading the Youtube API from PhantomJS

The following code will retrieve the duration of a video from the Youtube API. The output must be in JSON, because PhantomJS currently doesn’t handle the XML correctly (from email threads it appears this will be fixed in a future release)

address = '' + id + '?v=2&alt=json';, function (status) {
   var duration = page.evaluate(function(){
       var data = JSON.parse(document.querySelector("pre").innerText);
   console.log("video duration: " + duration);