close

  
<p> var id= acre.request.params.id || "/en/radiohead";  

var query=[{ 
  "id": id,  
  "key": [{
    "namespace": "/wikipedia/en_title",
    "value":     null
  }]
}]
    
    var result=acre.freebase.mqlread(query).result
        
        var images=[]
            
            if (result[0]){
              var wiki=result[0].key[0].value;
              acre.write(wiki)
                //get its wikipedia images
                var url='http://en.wikipedia.org/w/api.php?action=query&amp;titles='+encodeURI(wiki)+'&amp;prop=images&amp;format=json'
                var result=JSON.parse(acre.urlfetch(url).body)
                        result=result.query.pages;
              var images=[]
              for(var i in result){
                images=result[i].images.map(function(v){
                  return v.title                
                })
                break                
              }
                  
                  var count=0;
                images.map(function(title){
                  url='http://en.wikipedia.org/w/api.php?action=query&amp;titles='+title+'&amp;prop=imageinfo&amp;iiprop=url&amp;format=json'
                  console.log(url)
                    var result=JSON.parse(acre.urlfetch(url))
                      console.log(result)
                        count++;
                  if(count==images.length){
                    
                   console.log('done') 
                  }
                })
                  
                }

acre.write(JSON.stringify(images)) </p>

Comments

Hide