fork download
  1. #! /usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. from BeautifulSoup import BeautifulSoup
  4.  
  5. def main():
  6. soup = BeautifulSoup(open("./htmlcode.html"))
  7.  
  8. contents = soup.findAll('table',{"class" : "std_tbl"})
  9. for c in contents:
  10. rows = c.findAll('tr')
  11. col_value(rows)
  12. print "**************"
  13.  
  14. def col_value(rows):
  15. for row in rows:
  16. cols = row.findAll('td')
  17. for col in cols:
  18. print col.text,
  19. print ""
  20.  
  21. if __name__ == "__main__":
  22. main()
  23.  
Runtime error #stdin #stdout #stderr 0.01s 7892KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "prog.py", line 3, in <module>
ImportError: No module named BeautifulSoup