var x = require('x-ray')();
var maxCount=0;
var businessWithMaxRec='';
x('http://www.homeimprovementpages.com.au/search/arborists/nsw/wollongong','.basic-listing',[{pageName:'.basic-listing__title',maxRecom:'.basic-listing__recommendations'}])(function(err,obj){
for(var i=0;i<obj.length;i++){
var topAboristCards = obj[i];
for(var res in topAboristCards){
switch(res){
case 'pageName':{
var currentPageName = topAboristCards[res];
}
case 'maxRecom':{
var str = topAboristCards[res];
var maxNum = parseInt(str.substr(0,str.indexOf(' ')));
if(maxNum > maxCount){
maxCount = maxNum;
businessWithMaxRec = currentPageName;
}
}
}
}
}
console.log(maxCount + 'Reccomendations for page :::' + businessWithMaxRec);
})