Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在NodeJS上使用jQuery的函数css()_Jquery_Css_Node.js_Request_Cheerio - Fatal编程技术网

在NodeJS上使用jQuery的函数css()

在NodeJS上使用jQuery的函数css(),jquery,css,node.js,request,cheerio,Jquery,Css,Node.js,Request,Cheerio,我目前正在使用NodeJS来废弃包含以下模块的网页:Cheerio和Request 是否可以在NodeJS中使用css()jQuery函数 request({uri: website}, function(error, response, body) { var $ = cheerio.load(body); myItemColor = $('.myitem').css('color'); console.log(myItemColor); }); 我想检索给定jQuery对象

我目前正在使用NodeJS来废弃包含以下模块的网页:Cheerio和Request

是否可以在NodeJS中使用css()jQuery函数

request({uri: website}, function(error, response, body) {

  var $ = cheerio.load(body);
  myItemColor = $('.myitem').css('color');
  console.log(myItemColor);

});
我想检索给定jQuery对象的css属性

谢谢你的帮助

是的

但是您需要在DOM中运行jQuery,这样才能工作。查看my,特别是了解如何使用为下载HTML站点创建服务器端DOM

PS:我还没有试过,但它也应该能与css功能一起工作(我看不出有什么理由不能)。

如果这解决了问题,请a)将其标记为答案,b)投票表决。谢谢:-)!