Closed iCrackk closed 5 years ago
So I want to select all the 'p span' element of the html that looks similar to this:
This is the first one
This is the second one
This is the third one
and this is what my code looks like: const xray = require('x-ray'); const x = xray();
x(url,'p span')(function(err,product){ if(err == null) console.log(product); else console.log(err); })
but the problem is that it only displays the first element that is this: "This is the first one"
So is there anything that I'm missing? I want to select and display all of the 'p span' elements in this case it would look like:
<p><span>This is the second one</span></p> <p><span>This is the third one</span></p>
Any help would be much appreciated.
Please read the documentation about collections. This should get things working:
x(url, { products: ['p span'] })(function(err, data){ if(err == null) console.log(data); else console.log(err); })
So I want to select all the 'p span' element of the html that looks similar to this:
This is the first one
This is the second one
This is the third one
and this is what my code looks like: const xray = require('x-ray'); const x = xray();
x(url,'p span')(function(err,product){ if(err == null) console.log(product); else console.log(err); })
but the problem is that it only displays the first element that is this: "This is the first one"
So is there anything that I'm missing? I want to select and display all of the 'p span' elements in this case it would look like:
This is the first one
Any help would be much appreciated.