title: How to extract specific data from HTML files?
body: <p>I have some code that will extract pairs of data from an HTML file using BS4:</p>
  
  <pre><code>from bs4 import BeautifulSoup
  readfile = """
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta name="generator"
      &lt;title&gt;&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
  
      &lt;table align="center" border="1" cellpadding="0" cellspacing="1" width="650"&gt;
    &lt;tr&gt;
      &lt;td&gt;
      &lt;font size="1"&gt; Title1&lt;/font&gt;
      &lt;br /&gt; &lt;/td&gt;
      &lt;td&gt;
      &lt;font size="1"&gt; TItle2 type&lt;/font&gt;
      &lt;br /&gt; &lt;/td&gt;
      &lt;td&gt;
      &lt;font size="1"&gt; Title3&lt;/font&gt;
      &lt;br /&gt; 
      &lt;font size="2"&gt;value1&lt;/font&gt;&lt;/td&gt;
      &lt;td&gt;
      &lt;font size="1"&gt; Title4 ID&lt;/font&gt;
      &lt;br /&gt; 
      &lt;font size="2"&gt;value2&lt;/font&gt;&lt;/td&gt;
    &lt;/tr&gt;
   """
  
  soup = BeautifulSoup(readfile, "html.parser")
   tables = soup.findChildren('table')
  
  for title in soup.find_all("font", {"size": "1"}):
      value = title.find_next_sibling("font", {"size": "2"})
      print (title.text, ":", value.text if value else "No Value")
  </code></pre>
  
  <p>Let's say that I have 30 rows in total. I only want 4 of the value pairs so I can then insert them into a rdbms. </p>
  
  <p>Should I try then to use a list of the size:1 values I want get the size:2 value? Have looked up some examples on BS4 and it is not sinking in. 
  Thanks</p>