【发布时间】:2018-05-20 11:50:52
【问题描述】:
我正在尝试使用 beautifulsoup() 函数 python 将 HTML 表转换为 json,我能够将其他一些表转换为 json,但这是不同的类型。
我正在尝试实现这样的目标:
[{
"name": "abc",
"age": "21",
"sex": "m",
"loction": "us",
"language": "en"
}, {
"name": "xyz",
"age": "25",
"sex": "f",
"loction": "us",
"language": "en"
}]
表格是:
<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>
感谢您的帮助
【问题讨论】:
标签: python json beautifulsoup