title: Extract HTML tags and data from text
body: <p>I'm using Python 2.7 to try and do a simple call to a website to extract the HTML data, which I've managed with the code below.</p>
  
  <pre><code>import requests
  from HTMLParser import HTMLParser
  
  name = "Mark"
  surname = "Jacobs"
  
  def req_getPageHTML(nume, prenume):
      url = "http://sample.com/page.aspx&amp;Name=" + name + "&amp;surname=" + surname
      response = requests.get(url).text
      return response
  
  page_code = req_getPageHTML(nume, prenume)
  
  htmlp = HTMLParser()
  
  print htmlp.feed(page_code)
  </code></pre>
  
  <p>The next thing that I want to do is somehow extract or parse this <code>UNICODE</code> response (<code>print type(page_code)</code> returns <code>UNICODE</code>) to somehow extract some information from it.</p>
  
  <p>Specifically, from the below sample HTML which I can get back, I want to extract the values (numbers which are slightly inset in the below HTML code and also prefixed with a <code>&gt;</code> - this doesn't exist in the HTML code, it's just for being easily identified by you guys).</p>
  
  <pre><code>...
  &lt;tr class="tr1" OnClick="lockBac();"&gt;
      &lt;td class="tdB" rowspan="2" nowrap="nowrap"&gt;1&lt;/td&gt;
      &lt;td class="tdB" rowspan="2" nowrap="nowrap"&gt;Jacobs D &lt;br/&gt;Mark&lt;/td&gt;
      &lt;td class="tdB" rowspan="2" align="Center"&gt;Math speciality&lt;/td&gt;
      &lt;td class="tdB" rowspan="2" align="Center"&gt;Advanced User&lt;/td&gt;
          &gt;   &lt;td class="tdB" rowspan="2" align="Center"&gt;6.95&lt;/td&gt;
          &gt;   &lt;td class="tdB" rowspan="2" align="Center"&gt;7.9&lt;/td&gt;
          &gt;   &lt;td class="tdB" rowspan="2" align="Center"&gt;7.9&lt;/td&gt;
      &lt;td class="tdB" colspan="4" align="Center"&gt;&lt;/td&gt;
      &lt;td class="tdB" rowspan="2" align="Center"&gt;English&lt;/td&gt;
      &lt;td class="tdB" rowspan="2" align="Center"&gt;B2-B2-B2-B2-B2&lt;/td&gt;
      &lt;td class="tdB" colspan="3" align="Center"&gt;Mathematics MATH-INFO&lt;/td&gt;
      &lt;td class="tdB" colspan="3" align="Center"&gt;Informatics&lt;/td&gt;
      &lt;td bgcolor="lightgreen" class="tdB" rowspan="2" align="Center"&gt;&lt;/td&gt;
      &lt;td class="tdB" rowspan="2" align="Center"&gt;8.88&lt;/td&gt;
      &lt;td class="tdB" rowspan="2" align="Center"&gt;Success&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr class="tr1" OnClick="lockBac();"&gt;
      &lt;td class="tdB"&gt;&lt;/td&gt;
      &lt;td class="tdB"&gt;&lt;/td&gt;
      &lt;td class="tdB"&gt;&lt;/td&gt;
      &lt;td class="tdB"&gt;&lt;/td&gt;
          &gt;    &lt;td class="tdB"&gt;9.35&lt;/td&gt;
          &gt;    &lt;td class="tdB"&gt;&lt;/td&gt;
          &gt;    &lt;td class="tdB"&gt;9.35&lt;/td&gt;
          &gt;    &lt;td class="tdB"&gt;9.4&lt;/td&gt;
      &lt;td class="tdB"&gt;&lt;/td&gt;
          &gt;    &lt;td class="tdB"&gt;9.4&lt;/td&gt;
  &lt;/tr&gt;
  ...
  </code></pre>
  
  <p>What these numbers represent is Exam scores, which I will later put in a DB.</p>
  
  <p>Now, I'm trying to look for an efficient way to extract these numbers as I would prefer to leave parsing the text to look for each element (manually with <code>SUBSTR</code> and so on) as a last option.</p>
  
  <p>I did come across HTMLParser, which as you can see is also imported into my code, but the bottom <code>print</code> returns <code>None</code>. </p>
  
  <p>I was under the impression that I can use this library to parse the text received from <code>response</code> and there would be an easier way to specify a tag ID (or something similar) and extract the relevant information from it (like it is shown in the <a href="https://docs.python.org/2/library/htmlparser.html#examples" rel="nofollow">HTMLParser examples section</a>), but I can't get the necessary information I want from using the <code>feed</code> method.</p>
  
  <p>Maybe I'm not understanding this correctly and maybe I'm not using the appropriate tool, so that is why I also explained my goal.</p>
  
  <p>I would appreciate any help in correcting or pointing me into the right direction.</p>