Performant parsing of HTML pages with Node.js and XPath

前端 未结 6 2119
情书的邮戳
情书的邮戳 2020-12-07 21:10

I\'m into some web scraping with Node.js. I\'d like to use XPath as I can generate it semi-automatically with several sorts of GUI. The problem is that I cannot find a way t

6条回答
  •  自闭症患者
    2020-12-07 21:34

    With just one line, you can do it with xpath-html:

    const xpath = require("xpath-html");
    
    const node = xpath.fromPageSource(html).findElement("//*[text()='Made with love by']");
    

提交回复
热议问题