Navigating table by using th text
<p>I have the following table:</p>

<pre><code>&lt;table class="information"&gt;
  &lt;tr&gt; .... lots of rows with &lt;th&gt; and &lt;td&gt;&lt;/tr&gt;
  &lt;tr&gt;
   &lt;th&gt;Nationality&lt;/th&gt;
   &lt;td&gt;&lt;a href=".."&gt;Stackoverflowian&lt;/a&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p>I want to find the text in inside the td tags under the th with "nationality" in it. How should I navigate there? I'm using Beautifulsoup and Python.</p>

<p><strong>Added that there is lots of th and td tags above this that, to underline that it isnt sufficient to just find first th</strong></p>

<p>I've modified this answer as you gave a specific HTML page you're trying to parse.</p>

<pre><code>r = requests.get("http://https://en.wikipedia.org/wiki/Usain_Bolt")
# test that we loaded the page successfully!
soup = BeautifulSoup(r.text, "html.parser")

thTag = soup.find('th', text='Nationality'):
tdTag = thTag.next_sibling.next_sibling

print(tdTag.text)
&gt;&gt;&gt;'Jamaican'
</code></pre>

python beautifulsoup