I want to find the value of a <td>
that "belongs" to a <th>
? I can search for the text in the <th>
tag and find it, but I do not know the value and there is no class to search for. The number of columns can vary as well. So all I have is the text in the <th>
.
Example of a table:
<table>
<tbody>
<tr>
<th colspan="8">
<span>
<a href="/link">Table Title</a>
</span>
</th>
</tr>
<tr>
<th>Info1</th>
<th>Info2</th>
<th>Info3</th>
<th>Info4</th>
<th>Info5</th>
</tr>
<tr>
<td>Value1</td>
<td>Value2</td>
<td>Value3</td>
<td>Value4</td>
<td>Value5</td>
</tr>
</tbody>
</table>
Let's say I want to find Value4 which "belongs" to Info4, how is this possible in BeautifulSoup?
Python 3.7.4 and BeautifulSoup 4.9.3.