title: How to extract HTML table following a specific heading?
body: <p>I am using BeautifulSoup to parse HTML files. I have a HTML file similar to this:</p>
  
  <pre><code>&lt;h3&gt;Unimportant heading&lt;/h3&gt;
  &lt;table class="foo"&gt;
    &lt;tr&gt;
      &lt;td&gt;Key A&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;A value I don't want&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  
  
  &lt;h3&gt;Unimportant heading&lt;/h3&gt;
  &lt;table class="foo"&gt;
    &lt;tr&gt;
      &lt;td&gt;Key B&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;A value I don't want&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  
  
  &lt;h3&gt;THE GOOD STUFF&lt;/h3&gt;
  &lt;table class="foo"&gt;
    &lt;tr&gt;
      &lt;td&gt;Key C&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;I WANT THIS STRING&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  
  
  &lt;h3&gt;Unimportant heading&lt;/h3&gt;
  &lt;table class="foo"&gt;
    &lt;tr&gt;
      &lt;td&gt;Key A&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;A value I don't want&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>I want to extract the string "I WANT THIS STRING". The perfect solution would be to get <strong>the first table following the h3 heading called "THE GOOD STUFF"</strong>. I have no idea how to do this with BeautifulSoup - I only know how to extract a table with a specific class, or a table <em>nested within</em> some particular tag, but not <em>following</em> a particular tag.</p>
  
  <p>I think a fallback solution could make use of the string "Key C", assuming it's unique (it almost certainly is) and appears in only that one table, but I'd feel better with going for the specific h3 heading.</p>