I'm currently using NodeJS to scrap a web page with the following modules: Cheerio and Request
Is it possible to use the css() jQuery function in NodeJS ?
request({uri: website}, function(error, response, body) {
var $ = cheerio.load(body);
myItemColor = $('.myitem').css('color');
console.log(myItemColor);
});
I would like to retrieve a css property of a given jQuery object.
Thanks for your help!
Yes, it is.
But you need to run jQuery inside a DOM so that this works. Check out my jQuery on the server sample, especially this part of the app.js file to see how you can use jsdom to create a server-side DOM for a download HTML site.
PS: I haven't tried it, but it should work with the css function as well (I don't see any reason why it shouldn't).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With