title: Search HTML line by line with regex in Python
body: <p>I'm attempting to create a dictionary of hours based off of this calendar: <a href="http://disneyworld.disney.go.com/parks/magic-kingdom/calendar/" rel="nofollow">http://disneyworld.disney.go.com/parks/magic-kingdom/calendar/</a></p>
  
  <pre><code>&lt;td class="first"&gt; &lt;div class="dayContainer"&gt;
        &lt;a href="/parks/magic-kingdom/calendardayview/?asmbly_day=20120401"&gt; 
           &lt;p class="day"&gt; 1
           &lt;/p&gt; &lt;p class="moreLink"&gt;Park Hours&lt;br /&gt;8:00 AM - 12:00 AM&lt;br /&gt;&lt;br/&gt;Extra Magic Hours&lt;br /&gt;7:00 AM - 8:00 AM&lt;br /&gt;&lt;br/&gt;Extra Magic Hours&lt;br /&gt;12:00 AM - 3:00 AM&lt;br /&gt;&lt;br/&gt;
           &lt;/p&gt; 
        &lt;/a&gt; 
     &lt;/div&gt;
  &lt;/td&gt; 
  </code></pre>
  
  <p>Each of the calendar entries are on a single line, so I figured it would be best to just go through the HTML line by line, and if that line contains hours, add those hours to a dictionary for the corresponding date (some days have multiple hour entries).</p>
  
  <pre><code>import urllib
  import re
  source = urllib.urlopen('http://disneyworld.disney.go.com/parks/magic-kingdom/c\
  alendar/')
  page = source.read()
  prkhrs = {}
  
  def main():
      parsehours()
  
  def parsehours():
      #look for #:## AM - #:## PM                                                 
      date = r'201204\d{02}'
      hours = r'\d:0{2}\s\w{2}\s-\s\d:0{2}\s\w{2}'
      #go through page line by line                                               
      for line in page:
          times = re.findall(hours, line)
          dates = re.search(date, line)
          if dates:
              start = dates.start()
              end = dates.end()
              curdate = line[start:end]
          #if #:## - #:## is found, a date has been found                         
          if times:
              #create dictionary from date, stores hours in variable              
              #extra magic hours(emh) are stored in same format.                  
              #if entry has 2/3 hour listings, those listings are emh             
              prkhrs[curdate]['hours'] = times
      #just print hours for now. will change later                                
      print prkhrs
  </code></pre>
  
  <p>The problem I encounter is that when I put 'print line' inside the for loop that goes through the page, it prints it out a character at a time, which I'm assuming is what's messing things up.</p>
  
  <p>Right now, the 'print prkhrs' just prints nothing, but using re.findall for both the dates and the hours prints out the correct times, so I know the regex works. Any suggestions on how I can get it to work?</p>