title: Fastest, easiest, and best way to parse an HTML table?
body: <p>I'm trying to get this table <a href="http://www.datamystic.com/timezone/time_zones.html">http://www.datamystic.com/timezone/time_zones.html</a> into array format so I can do whatever I want with it. Preferably in PHP, python or JavaScript.</p>
  
  <p>This is the kind of problem that comes up a lot, so rather than looking for help with this specific problem, I'm looking for ideas on how to solve all similar problems.</p>
  
  <p>BeautifulSoup is the first thing that comes to mind.
  Another possibility is copying/pasting it in TextMate and then running regular expressions.</p>
  
  <p>What do you suggest?</p>
  
  <p>This is the script that I ended up writing, but as I said, I'm looking for a more general solution.</p>
  
  <pre><code>from BeautifulSoup import BeautifulSoup
  import urllib2
  
  
  url = 'http://www.datamystic.com/timezone/time_zones.html';
  response = urllib2.urlopen(url)
  html = response.read()
  soup = BeautifulSoup(html)
  tables = soup.findAll("table")
  table = tables[1]
  rows = table.findAll("tr")
  for row in rows:
      tds = row.findAll('td')
      if(len(tds)==4):
          countrycode = tds[1].string
          timezone = tds[2].string
          if(type(countrycode) is not type(None) and type(timezone) is not type(None)):
              print "\'%s\' =&gt; \'%s\'," % (countrycode.strip(), timezone.strip())
  </code></pre>
  
  <p>Comments and suggestions for improvement to my python code welcome, too ;)</p>