Can I load a local html file with the cheerio package in node.js?

后端 未结 3 2008
再見小時候
再見小時候 2020-12-28 14:19

I have a few html files on my harddrive that I\'d like to use jquery on to extract data from. Is this possible to do using cheerio? I\'ve tried giving cheerio the local pa

3条回答
  •  青春惊慌失措
    2020-12-28 14:37

    The input is an html string, so you need to read the html content yourself:

    var fs = require('fs');
    
    cheerio.load(fs.readFileSync('path/to/file.html'));
    

提交回复
热议问题