使用指定模板从html源文件提取数据

使用指定模板从html源文件提取数据,html,node.js,templates,extraction,Html,Node.js,Templates,Extraction,我想通过指定的模板解析源文件中的值 比如说,我有: 模板: <div>{value}</div> <span id="id1">{value}</span> <div><span>{value}</span></div> <h1>The source file can have other parts but will contain the specified template str

我想通过指定的模板解析源文件中的值

比如说,我有:

模板:

<div>{value}</div>
<span id="id1">{value}</span>
<div><span>{value}</span></div>
<h1>The source file can have other parts but will contain the specified template structure</h1>
<div>value 1</div>
<span id="id1">value 2</span>
<div>or a bit more complex content...<span>value 3</span><a>abc</a></div>
<h2>other file content again</h2>
{value}
{value}
{value}
源文件:

<div>{value}</div>
<span id="id1">{value}</span>
<div><span>{value}</span></div>
<h1>The source file can have other parts but will contain the specified template structure</h1>
<div>value 1</div>
<span id="id1">value 2</span>
<div>or a bit more complex content...<span>value 3</span><a>abc</a></div>
<h2>other file content again</h2>
源文件可以包含其他部分,但将包含指定的模板结构
值1
价值2
或者更复杂一点的内容…价值3abc
请重新输入其他文件内容
预期的输出是一个数组:[值1、值2、值3]

有人知道用于此目的的NodeJS模块吗


谢谢大家!

似乎没有用于此目的的lib。 我有自己的解决方案,通过另一种方式思考,所以问题应该是:如何解析web内容。 答案是:我们可以像这里讨论的那样使用xpath: