title: Convert HTML into CSV
body: <p>I want to convert a HTML table as obtained from the script below into a CSV file, but  got type error as follows:</p>
  
  <blockquote>
    <p>TypeError: sequence item 0: expected string, Tag found</p>
  </blockquote>
  
  <pre><code>from bs4 import BeautifulSoup
  import urllib2
  
  url = 'http://www.data.jma.go.jp/obd/stats/etrn/view/monthly_s3_en.php?block_no=47401&amp;view=1'
  html = urllib2.urlopen(url).read()        
  soup = BeautifulSoup(html)
  table = soup.find_all('table', class_='data2_s')
  rows = table[0].find_all('tr')
  </code></pre>
  
  <p>How is the easiest way to convert it into a CSV file?
  I tried as:</p>
  
  <pre><code>fo = open('fo.txt','w')
  for r in rows:
      fo.write(str(r.txt) + '\n')
  fo.close()
  </code></pre>
  
  <p>but it wrote 'none'</p>
  
  <p>The HTML is like this:</p>
  
  <pre><code>&lt;table class="data2_s"&gt;&lt;caption class="m"&gt;WAKKANAIÂ Â Â WMO Station ID:47401Â LatÂ 45&lt;sup&gt;o&lt;/sup&gt;24.9'NÂ Â LonÂ 141&lt;sup&gt;o&lt;/sup&gt;40.7'E&lt;/caption&gt;&lt;tr&gt;&lt;th scope="col"&gt;Year&lt;/th&gt;&lt;th scope="col"&gt;Jan&lt;/th&gt;&lt;th scope="col"&gt;Feb&lt;/th&gt;&lt;th scope="col"&gt;Mar&lt;/th&gt;&lt;th scope="col"&gt;Apr&lt;/th&gt;&lt;th scope="col"&gt;May&lt;/th&gt;&lt;th scope="col"&gt;Jun&lt;/th&gt;&lt;th scope="col"&gt;Jul&lt;/th&gt;&lt;th scope="col"&gt;Aug&lt;/th&gt;&lt;th scope="col"&gt;Sep&lt;/th&gt;&lt;th scope="col"&gt;Oct&lt;/th&gt;&lt;th scope="col"&gt;Nov&lt;/th&gt;&lt;th scope="col"&gt;Dec&lt;/th&gt;&lt;th scope="col"&gt;Annual&lt;/th&gt;&lt;/tr&gt;&lt;tr class="mtx" style="text-align:right;"&gt;&lt;td style="text-align:center"&gt;1938&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;-5.2&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;-4.9&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;-0.6&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;4.7&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;9.5&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;11.6&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;17.9&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;22.2&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;16.5&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;10.7&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;3.3&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;-4.7&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;6.8&lt;/td&gt;&lt;/tr&gt;
  &lt;tr class="mtx" style="text-align:right;"&gt;&lt;td style="text-align:center"&gt;1939&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;-7.5&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;-6.6&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;-1.4&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;4.0&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;7.5&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;13.0&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;17.4&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;20.0&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;17.4&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;9.7&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;3.0&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;-2.5&lt;/td&gt;&lt;td class="data_0_0_0_0"&gt;6.2&lt;/td&gt;&lt;/tr&gt;
  </code></pre>