通过cheerio(nodejs)获取文本

时间:2018-07-10 04:43:22

标签: html node.js cheerio

我试图通过nodejs中的cheerio在blockquote元素中获取文本。我正在解析的HTML:

std::string compileCommand{ "g++ file.cpp -o file -L <path1> -L <path2> -L <path3> -lstdc++ -lgcc_s" }; 

Cheerio功能:

<div id ="p178153953" class="post reply">
    <div class= ...</div>
    <div class= ...</div>
    <div class= ...</div>
    <blockquote class= "postMessage" id="m178153881">
        <a href=<"#p178153881" class="quotelink">>><178153881</a>
        <br>
        "GET THIS TEXT"
    </blockquote>
</div>

这将记录一个空字符串。 作为参考,request(link, function(err, res, html){ var $ = cheerio.load(html); var postContent = $(`#${postId} blockquote`); var postContentText = postContent.text(); console.log(postContentText); }); 参考postId

0 个答案:

没有答案