html-tables-to-json
v0.0.3
Published
Parser for HTML to JSON
Downloads
366
Readme
Installation
$ npm install html-tables-to-json
Usage
import { CheerioTableParser } from "html-tables-to-json"
const tableParser = new CheerioTableParser()
const result = tableParser.parse(
`
<table>
<tbody>
<tr>
<th>header 1</th>
<th>header 2</th>
</tr>
<tr>
<td>cell 1</td>
<td>cell 2</td>
<td>cell 3</td>
</tr>
<tr>
<td colspan="2">cell 4</td>
</tr>
</tbody>
</table>
`
)
console.log(result[0])
// => output
// [
// ["header 1", "header 2"],
// ["cell 1", "cell 2", "cell 3"],
// ["cell 4", "cell 4"],
// ]