I'm having some troubles with the X-ray. I feel that isn't the x-ray specifically but instead the javascript.
var Xray = require('x-ray');
var xray = Xray();
var brasil = [];
function stringToNumber(str){
var number;
for(var i=0;i<str.length-1;i++){
if(number == undefined && Number(str[i]) < 10){
number = str[i];
} else if (number != undefined && Number(str[i]) < 10) {
number = number + str[i];
} else {
break;
}
}
return Number(number);
}
xray('http://www.footballzz.com/equipa.php?id=87&epoca_id=143', {
a: xray('tr', [{
name: '.text',
percentage: 'td:nth-child(2)'
}])
})(function(err, obj){
for(var i =0;i<obj.a.length-1;i++){
if(obj.a[i].name == "Brazil"){
obj.a[i].percentage = stringToNumber(obj.a[i].percentage);
brasil.push(obj.a[i]);
}
}
console.log(brasil);
})
So basically what I'm trying to do is get the information out of x-ray and then work with it. I'm trying to store the information into a object but when I try to access it only gives me the last option. If someone could assist me I would appreciate. Thank you, Renan Cidale
You may try phantom Javascript driver for x-ray.