title: Is there any way function to count the number of table tags using BeautifulSoup?
body: <p>I am trying to scrap through Wikipedia website and display the tables, but the table number will be specified by the user. </p>
  
  <p>So I thinking, get the number of table tags from the page, loop through and display the number specified by the user and display the table.</p>
  
  <p>So far I am only able to display the contents of the table. </p>
  
  <pre><code>from bs4 import BeautifulSoup
  import urllib2
  from lxml.html import fromstring
  
  
  import re
  
  wiki = "http://en.wikipedia.org/wiki/List_of_Test_cricket_records"
  
  header = {'User-Agent': 'Mozilla/5.0'} #Needed to prevent 403 error on Wikipedia
  
  req = urllib2.Request(wiki,headers=header)
  
  page = urllib2.urlopen(req)
  
  soup = BeautifulSoup(page)
  
  
  
  table = soup.findAll("table")
  
  
  for row in table :
  
      td=row.findAll("tr")
  
      for data in td :
  
          cells = data.findAll("td")
  </code></pre>
  
  <hr>
  
  <p>is there a better way. Please guide me.</p>