Javascript Cheerio.js不支持非内联样式?
我目前正在使用node.js来抓取另存为.htm的word文档,然后将其重写为shell 我已经创建了Javascript Cheerio.js不支持非内联样式?,javascript,node.js,cheerio,Javascript,Node.js,Cheerio,我目前正在使用node.js来抓取另存为.htm的word文档,然后将其重写为shell 我已经创建了标记,但这些word文档的保存方式是,我必须通过查找左边距来查找它们。像这样: $("p","td:nth-child(2)").each(function(){ var marginLeft = this.css("margin-left"); } 到目前为止,我的工作还不错。我面临的唯一问题是,当样式实际通过类应用时 以下是冲突类: p.RNBullet1, li.RNBullet1
$("p","td:nth-child(2)").each(function(){
var marginLeft = this.css("margin-left");
}
到目前为止,我的工作还不错。我面临的唯一问题是,当样式实际通过类应用时
以下是冲突类:
p.RNBullet1, li.RNBullet1, div.RNBullet1{
mso-style-name:"*RN Bullet1";
mso-style-unhide:no;
mso-style-link:"*RN Bullet1 Char";
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.2in;
text-indent:-.2in;
mso-pagination:widow-orphan;
mso-list:l12 level1 lfo5;
font-size:11.0pt;
font-family:"Arial","sans-serif";
mso-fareast-font-family:"Times New Roman";
}
当它有一个值时,它将返回一个未定义的值
对这一点的任何了解都会有帮助,我在这里已经疯了。正如上面vkurchatkin所指出的,cheerio只是遍历DOM。它不读样式表 答案是: 基本上我给cheerio装了果汁
Juice会将styes转换为内联。试试Phantom.JS
cheerio
只是一个DOM遍历工具,它不计算样式。@vkurchatkin op可能试图在node js中使用cheerio。据我所知,幻影js不能在节点js中使用。@AkshatJiwanSharma是的,他可能需要类似的东西。我希望PhantomJS只是一个节点模块……如果cheerio只是一个DOM遍历工具的话。那么我想我有几种方法可以处理它。我可以在cheerior之前使用Juice获取css样式并将其作为内联应用。或者这件鬼怪的事。我得报告我走的路线。谢谢