簡體   English   中英

Cheerio.js沒有抓住非內聯樣式?

[英]Cheerio.js not grabbing non inline styles?

我目前正在使用node.js來刮取保存為.htm的word文檔,然后將其重寫為shell。

我創建了<li>標簽,但這些word文檔的保存方式我必須通過尋找margin-left來尋找它們。 像這樣:

$("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。 它不會讀取樣式表

這就是答案: https//npmjs.org/package/juice

基本上我裝了cheerio什么果汁回來了。

果汁將變成內聯。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM