I have the following table:
<tr> .... lots of rows with <th> and <td></tr>
th tag, then get its next sibling:
soup = BeautifulSoup(html) ths = soup.find_all('th') for th in ths: if th.text == "Nationality": print th.next_sibling.next_sibling.text # Stackoverflowian
We need to do
next_sibling twice because the first one will give the newline.