How to parse an HTML table with rowspans in Python?
<p><strong>The problem</strong></p>

<p>I'm trying to parse an HTML table with rowspans in it, as in, I'm trying to parse my college schedule.</p>

<p>I'm running into the problem where if the last row contains a rowspan, the next row is missing a TD where the rowspan is now that TD that is missing.</p>

<p>I have no clue how to account for this and I hope to be able to parse this schedule.</p>

<p><strong>What I tried</strong></p>

<p>Pretty much everything I can think of.</p>

<p><strong>The result I get</strong>
</p>

<pre><code>[
    {
        'blok_eind': 4,
        'blok_start': 3,
        'dag': 4, # Should be 5
        'leraar': 'DOODF000',
        'lokaal': 'ALK C212',
        'vak': 'PROJ-T',
    },
]
</code></pre>

<p>As you can see, there's a <code>vak</code> key with the value <code>PROJ-T</code> in the output snippet above, <code>dag</code> is <code>4</code> while it's supposed to be <code>5</code> (a.k.a Friday/Vrijdag), as seen here:</p>

<p><img src="http://i.imgur.com/068mi1E.png" alt="Table"></p>

<p><strong>The result I want</strong></p>

<p>A Python dict() that looks like the one posted above, but with the right value</p>

<p>Where:</p>

<ul>
<li><code>day</code>/<code>dag</code> is an int from 1~5 representing Monday~Friday</li>
<li><code>block_start</code>/<code>blok_start</code> is an int that represents when the course starts (Time block, left side of table)</li>
<li><code>block_end</code>/<code>blok_eind</code> is an int that represent in what block the course ends</li>
<li><code>classroom</code>/<code>lokaal</code> is the classroom's code the course is in</li>
<li><code>teacher</code>/<code>leraar</code> is the teacher's ID </li>
<li><code>course</code>/<code>vak</code> is the ID of the course</li>
</ul>

<p><strong>Basic HTML Structure for above data</strong>
</p>

<pre><code>&lt;center&gt;
    &lt;table&gt;
        &lt;tr&gt;
            &lt;td&gt;
                &lt;table&gt;
                    &lt;tbody&gt;
                        &lt;tr&gt;
                            &lt;td&gt;
                                &lt;font&gt;
                                    TEACHER-ID
                                &lt;/font&gt;
                            &lt;/td&gt;
                            &lt;td&gt;
                                &lt;font&gt;
                                    &lt;b&gt;
                                        CLASSROOM ID
                                    &lt;/b&gt;
                                &lt;/font&gt;
                            &lt;/td&gt;
                        &lt;/tr&gt;
                        &lt;tr&gt;
                            &lt;td&gt;
                                &lt;font&gt;
                                    COURSE ID
                                &lt;/font&gt;
                            &lt;/td&gt;
                        &lt;/tr&gt;
                    &lt;/tbody&gt;
                &lt;/table&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/table&gt;
&lt;/center&gt;
</code></pre>

<p><strong>The code</strong></p>

<p><em>HTML</em></p>

<pre><code>&lt;CENTER&gt;&lt;font size="3" face="Arial" color="#000000"&gt;
&lt;BR&gt;&lt;/font&gt;
  &lt;font size="6" face="Arial" color="#0000FF"&gt;
16AO4EIO1B
&amp;nbsp;&lt;/font&gt; &lt;font size="4" face="Arial"&gt;
IO1B
&lt;/font&gt;
  &lt;BR&gt;
  &lt;TABLE border="3" rules="all" cellpadding="1" cellspacing="1"&gt;
    &lt;TR&gt;
      &lt;TD align="center"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial" color="#000000"&gt;
Maandag 29-08
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
Dinsdag 30-08
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
Woensdag 31-08
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
Donderdag 01-09
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
Vrijdag 02-09
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
      &lt;TD rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD align="center" rowspan="2" nowrap=1&gt;&lt;font size="3" face="Arial"&gt;
&lt;B&gt;1&lt;/B&gt;
&lt;/font&gt; &lt;/TD&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
8:30
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
          &lt;TR&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
9:20
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=4 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD width="50%" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
BLEEJ002
&lt;/font&gt; &lt;/TD&gt;
            &lt;TD width="50%" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
&lt;B&gt;ALK B021&lt;/B&gt;
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
          &lt;TR&gt;
            &lt;TD colspan="2" width="50%" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
WEBD
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
      &lt;TD rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD align="center" rowspan="2" nowrap=1&gt;&lt;font size="3" face="Arial"&gt;
&lt;B&gt;2&lt;/B&gt;
&lt;/font&gt; &lt;/TD&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
9:20
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
          &lt;TR&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
10:10
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=4 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD width="50%" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
BLEEJ002
&lt;/font&gt; &lt;/TD&gt;
            &lt;TD width="50%" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
&lt;B&gt;ALK B021B&lt;/B&gt;
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
          &lt;TR&gt;
            &lt;TD colspan="2" width="50%" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
WEBD
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
      &lt;TD rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD align="center" rowspan="2" nowrap=1&gt;&lt;font size="3" face="Arial"&gt;
&lt;B&gt;3&lt;/B&gt;
&lt;/font&gt; &lt;/TD&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
10:25
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
          &lt;TR&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
11:15
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=4 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD width="50%" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
DOODF000
&lt;/font&gt; &lt;/TD&gt;
            &lt;TD width="50%" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
&lt;B&gt;ALK C212&lt;/B&gt;
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
          &lt;TR&gt;
            &lt;TD colspan="2" width="50%" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
PROJ-T
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
      &lt;TD rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD align="center" rowspan="2" nowrap=1&gt;&lt;font size="3" face="Arial"&gt;
&lt;B&gt;4&lt;/B&gt;
&lt;/font&gt; &lt;/TD&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
11:15
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
          &lt;TR&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
12:05
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=4 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD width="50%" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
BLEEJ002
&lt;/font&gt; &lt;/TD&gt;
            &lt;TD width="50%" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
&lt;B&gt;ALK B021B&lt;/B&gt;
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
          &lt;TR&gt;
            &lt;TD colspan="2" width="50%" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
MENT
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
      &lt;TD rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD align="center" rowspan="2" nowrap=1&gt;&lt;font size="3" face="Arial"&gt;
&lt;B&gt;5&lt;/B&gt;
&lt;/font&gt; &lt;/TD&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
12:05
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
          &lt;TR&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
12:55
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
      &lt;TD rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD align="center" rowspan="2" nowrap=1&gt;&lt;font size="3" face="Arial"&gt;
&lt;B&gt;6&lt;/B&gt;
&lt;/font&gt; &lt;/TD&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
12:55
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
          &lt;TR&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
13:45
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=4 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD width="50%" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
JONGJ003
&lt;/font&gt; &lt;/TD&gt;
            &lt;TD width="50%" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
&lt;B&gt;ALK B008&lt;/B&gt;
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
          &lt;TR&gt;
            &lt;TD colspan="2" width="50%" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
BURG
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
      &lt;TD rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD align="center" rowspan="2" nowrap=1&gt;&lt;font size="3" face="Arial"&gt;
&lt;B&gt;7&lt;/B&gt;
&lt;/font&gt; &lt;/TD&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
13:45
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
          &lt;TR&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
14:35
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=4 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD width="50%" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
FLUIP000
&lt;/font&gt; &lt;/TD&gt;
            &lt;TD width="50%" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
&lt;B&gt;ALK B004&lt;/B&gt;
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
          &lt;TR&gt;
            &lt;TD colspan="2" width="50%" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
ICT algemeen  Prakti
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
      &lt;TD rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD align="center" rowspan="2" nowrap=1&gt;&lt;font size="3" face="Arial"&gt;
&lt;B&gt;8&lt;/B&gt;
&lt;/font&gt; &lt;/TD&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
14:50
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
          &lt;TR&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
15:40
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=4 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD width="50%" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
KOOLE000
&lt;/font&gt; &lt;/TD&gt;
            &lt;TD width="50%" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
&lt;B&gt;ALK B008&lt;/B&gt;
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
          &lt;TR&gt;
            &lt;TD colspan="2" width="50%" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
NED
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
      &lt;TD rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD align="center" rowspan="2" nowrap=1&gt;&lt;font size="3" face="Arial"&gt;
&lt;B&gt;9&lt;/B&gt;
&lt;/font&gt; &lt;/TD&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
15:40
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
          &lt;TR&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
16:30
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
      &lt;TD rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD align="center" rowspan="2" nowrap=1&gt;&lt;font size="3" face="Arial"&gt;
&lt;B&gt;10&lt;/B&gt;
&lt;/font&gt; &lt;/TD&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
16:30
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
          &lt;TR&gt;
            &lt;TD align="center" nowrap=1&gt;&lt;font size="2" face="Arial"&gt;
17:20
&lt;/font&gt; &lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
      &lt;TD colspan=12 rowspan=2 align="center" nowrap="1"&gt;
        &lt;TABLE&gt;
          &lt;TR&gt;
            &lt;TD&gt;&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/TABLE&gt;
      &lt;/TD&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
    &lt;/TR&gt;
  &lt;/TABLE&gt;
  &lt;TABLE cellspacing="1" cellpadding="1"&gt;
    &lt;TR&gt;
      &lt;TD valign=bottom&gt; &lt;font size="4" face="Arial" color="#0000FF"&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;font size="3" face="Arial"&gt;
Periode1   29-08-2016 (35) - 04-09-2016 (35)   G r u b e r  &amp;amp;  P e t t e r s   S o f t w a r e
&lt;/font&gt;&lt;/CENTER&gt;
</code></pre>

<p><em>Python</em></p>

<pre><code>from pprint import pprint
from bs4 import BeautifulSoup
import requests

r = requests.get("http://rooster.horizoncollege.nl/rstr/ECO/AMR/400-ECO/Roosters/36"
                 "/c/c00025.htm")
daytable = {
    1: "Maandag",
    2: "Dinsdag",
    3: "Woensdag",
    4: "Donderdag",
    5: "Vrijdag"
}
timetable = {
    1: ("8:30", "9:20"),
    2: ("9:20", "10:10"),
    3: ("10:25", "11:15"),
    4: ("11:15", "12:05"),
    5: ("12:05", "12:55"),
    6: ("12:55", "13:45"),
    7: ("13:45", "14:35"),
    8: ("14:50", "15:40"),
    9: ("15:40", "16:30"),
    10: ("16:30", "17:20"),
}

page = BeautifulSoup(r.content, "lxml")

roster = []
big_rows = 2
last_row_big = False
# There are 10 blocks, each made up out of 2 TR's, run through them
for block_count in range(2, 22, 2):
    # There are 5 days, first column is not data we want
    for day in range(2, 7):
        dayroster = {
            "dag": 0,
            "blok_start": 0,
            "blok_eind": 0,
            "lokaal": "",
            "leraar": "",
            "vak": ""
        }
        # This selector provides the classroom
        table_bold = page.select(
            "html &gt; body &gt; center &gt; table &gt; tr:nth-of-type(" + str(block_count) + ") &gt; td:nth-of-type(" + str(
                day) + ") &gt; table &gt; tr &gt; td &gt; font &gt; b")

        # This selector provides the teacher's code and the course ID
        table = page.select(
            "html &gt; body &gt; center &gt; table &gt; tr:nth-of-type(" + str(block_count) + ") &gt; td:nth-of-type(" + str(
                day) + ") &gt; table &gt; tr &gt; td &gt; font")

        # This gets the rowspan on the current row and column
        rowspan = page.select(
            "html &gt; body &gt; center &gt; table &gt; tr:nth-of-type(" + str(block_count) + ") &gt; td:nth-of-type(" + str(
                day) + ")")

        try:
            if table or table_bold and rowspan[0].attrs.get("rowspan") == "4":
                last_row_big = True
                # Setting end of class
                dayroster["blok_eind"] = (block_count // 2) + 1
            else:
                last_row_big = False
                # Setting end of class
                dayroster["blok_eind"] = (block_count // 2)
        except IndexError:
            pass

        if table_bold:
            x = table_bold[0]
            # Classroom ID
            dayroster["lokaal"] = x.contents[0]

        if table:
            iter = 0
            for x in table:
                content = x.contents[0].lstrip("\r\n").rstrip("\r\n")
                # Cell has data
                if content != "":
                    # Set start of class
                    dayroster["blok_start"] = block_count // 2
                    # Set day of class
                    dayroster["dag"] = day - 1
                    if iter == 0:
                        # Teacher ID
                        dayroster["leraar"] = content
                    elif iter == 1:
                        # Course ID
                        dayroster["vak"] = content
                    iter += 1

        if table or table_bold:
            # Store the data
            roster.append(dayroster)

# Remove duplicates
seen = set()
new_l = []
for d in roster:
    t = tuple(d.items())
    if t not in seen:
        seen.add(t)
        new_l.append(d)
pprint(new_l)
</code></pre>

<p>Maybe it is better to use bs4 builtin function like "<strong>findAll</strong>" to parse your table.</p>

<p>You may use the following code :</p>

<pre><code>from pprint import pprint
from bs4 import BeautifulSoup
import requests

r = requests.get("http://rooster.horizoncollege.nl/rstr/ECO/AMR/400-ECO/Roosters/36"
                 "/c/c00025.htm")

content=r.content
page = BeautifulSoup(content, "html")
table=page.find('table')
trs=table.findAll("tr", {},recursive=False)
tr_count=0
trs.pop(0)
final_table={}

for tr in trs:
    tds=tr.findAll("td", {},recursive=False)
    if tds:
        td_count=0
        tds.pop(0)
        for td in tds:
            if td.has_attr('rowspan'):                              
                final_table[str(tr_count)+"-"+str(td_count)]=td.text.strip()
                if int(td.attrs['rowspan'])==4:
                    final_table[str(tr_count+1)+"-"+str(td_count)]=td.text.strip()
                if final_table.has_key(str(tr_count)+"-"+str(td_count+1)):
                    td_count=td_count+1         
            td_count=td_count+1
        tr_count=tr_count+1

roster=[]
for i in range(0,10): #iterate over time
    for j in range(0,5): #iterate over day
        item=final_table[str(i)+"-"+str(j)]
        if len(item)!=0:    
            block_eind=i+1          

            try:
                if final_table[str(i+1)+"-"+str(j)]==final_table[str(i)+"-"+str(j)]:
                        block_eind=i+2
            except:
                pass

            try:
                lokaal=item.split('\r\n \n\n')[0]
                leraar=item.split('\r\n \n\n')[1].split('\n \n\r\n')[0]
                vak=item.split('\n \n\r\n')[1]
            except:
                lokaal=leraar=vak="---"

            dayroster = {
                "dag": j+1,
                "blok_start": i+1,
                "blok_eind": block_eind,
                "lokaal": lokaal,
                "leraar": leraar,
                "vak": vak
            }


            dayroster_double = {
                "dag": j+1,
                "blok_start": i,
                "blok_eind": block_eind,
                "lokaal": lokaal,
                "leraar": leraar,
                "vak": vak
            }

            #use to prevent double dict for same event
            if dayroster_double not in roster:
                roster.append(dayroster)

print (roster)
</code></pre>

python html python-3.x beautifulsoup html-table