将htm页/表解析为json,nodejs

问题描述 投票:0回答:1

我正在搜索解析下面的html表解析为json:

 <div id="content">
    <h1>content-information</h1>
              <table class="testinformation">
        <thead>
            <tr>
                <th>hello</th>
                <th>test_text</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td><a href="https://example.com">hello1</a></td>
                <td><a href="https://example.com/test_text">test_text</a></td>
            </tr>
            <tr>
                <td><a href="https://example.com">hello2</a></td>
                <td><a href="https://example.com/test_text2">test_text2</a></td>
            </tr>            
        </tbody>
    </table>
  </div>

尝试cheerio,cheerio-table解析器,但没有成功......

json node.js html-parsing
1个回答
0
投票

你可以试试node-html-to-json

它易于使用且记录良好。

© www.soinside.com 2019 - 2024. All rights reserved.