I have this HTML and I went to toolslick.com to convert it to JSON. So, I got this JSON and I would like to know if is it possible to do exactly as it is, but in Python. What could I use? Regex? Some library? A loop? I tried some things but unsuccessfully. It doesn't need to be in JSON but I thought it was the best since I can acess the values using ['tr'][0] for example. Thank you.
HTML:
<tr>
<td>
<span class="theme1">1</span> Charisma
</td>
<td>
<span class="theme1">1</span> Smartness
</td>
<td>
<span class="theme1">1</span> Health
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>Age:
<span class="green">20</span>
</td>
</tr>
<tr>
<td colspan="3" class="active">Strength:
<span class="tooltip" data-tip="Lorem ipsum dolor sit amet, consectetur">
<icon>i-hand</icon> Hand
</span>
</td>
</tr>
<tr>
<td colspan="3" class="inactive">Weakness:
<span class="tooltip" data-tip="Donec egestas lectus quis">
<icon>i-feet</icon> Feet
</span>
</td>
</tr>
JSON:
{
"tr": [
{
"td": [
{
"span": {
"@class": "theme1",
"#text": "1"
},
"#text": "Charisma"
},
{
"span": {
"@class": "theme1",
"#text": "1"
},
"#text": "Smartness"
},
{
"span": {
"@class": "theme1",
"#text": "1"
},
"#text": "Health"
}
]
},
{
"td": [
"",
"",
{
"span": {
"@class": "green",
"#text": "20"
},
"#text": "Age:"
}
]
},
{
"td": {
"@colspan": "3",
"@class": "active",
"span": {
"@class": "tooltip",
"@data-tip": "Lorem ipsum dolor sit amet, consectetur",
"icon": "i-hand",
"#text": "Hand"
},
"#text": "Strength:"
}
},
{
"td": {
"@colspan": "3",
"@class": "inactive",
"span": {
"@class": "tooltip",
"@data-tip": "Donec egestas lectus quis",
"icon": "i-feet",
"#text": "Feet"
},
"#text": "Weakness:"
}
}
]
}