Closed salehmontazeran closed 5 years ago
You have to use CSS nth-of-type
:
{
...
game: '.contenedor-numero:nth-of-type(2)',
...
}
Another option is leaving it as an array (game: ['.contenedor-numero']
) and then inside the function get just the second item in the array:
}])(function(err, data) {
if (err) return console.log(err);
data.forEach(function(item) {
item.game = item.game[1];
});
return data;
});
['.contenedor-numero'][1]
doesn't work because you're defining the array and getting its 2nd element at the same time. Since there is no 2nd element because it's an array of just 1 element, you get undefined. You can test that in the developer console for example.
BTW don't leave out the if (err) return console.log(err)
of the ending function, it will save you of many headaches.
i want's to get the second item in the
game: ['.contenedor-numero'],
array :the html code struct is this :
I want's to scraping td elements that has
class="contenedor-numero "
with value of 38 ... but when i use['.contenedor-numero'][1]
nothing give me !!!how can i get second elemt of that array ???