I am trying to convert HTML table to json using beautifulsoup() function python, i was able to convert some other tables to json but this is of different kind.
I am trying to achieve something like this:
[{
"name": "abc",
"age": "21",
"sex": "m",
"loction": "us",
"language": "en"
}, {
"name": "xyz",
"age": "25",
"sex": "f",
"loction": "us",
"language": "en"
}]
Table is :
<table><colgroup><col /><col /><col /><col /><col /></colgroup>
<tbody>
<tr>
<th><span>name</span></th>
<th><span>age</span></th>
<th><span>sex</span></th>
<th><span>location</span></th>
<th><span>language</span></th>
</tr>
<tr>
<td colspan="1">
<p><span>abc</span></p>
</td>
<td colspan="1"><span>21</span></td>
<td colspan="1"><span>m</span></td>
<td colspan="1">us</td>
<td colspan="1">en</td>
</tr>
<tr>
<td colspan="1">
<p><span>xyz</span></p>
</td>
<td colspan="1"><span>25</span></td>
<td colspan="1">f</td>
<td colspan="1">us</td>
<td colspan="1">en</td>
</tr>
</tbody>
</table>
Some help is appreciated