import urllib2
import BeautifulSoup
def main():
infname = 'htmltable.html'
outfname = 'courses.txt'
with open(infname) as inf:
html = inf.read()
doc = BeautifulSoup.BeautifulSoup(html)
table = doc.find('table',{'id':'content'})
with open(outfname, 'w') as outf:
for row in table.findAll('tr'):
id,name,a,b,c,d = [cell.getText().strip() for cell in row.findAll('td')]
outf.write("{name}, {a}, {b}, {c}, {d}\n".format(id=id, name=name, a=a, b=b, c=c, d=d))
if __name__=="__main__":
main()
работает довольно хорошо, если вы предполагаете, что сохраненная страница начинается как
<html><head><title>Data Table</title></head><body>
<table id='content'>
<tr align=left bgcolor='#FFFFFF'> <td>EIT402 </td>
<td>ENGINEERING MATHEMATICS-IV</td>
<td align=center>4</td>
<td align=center>36</td>
<td align=center>40</td>
<td align=center>F</td>
</tr>
в результате
ENGINEERING MATHEMATICS-IV, 4, 36, 40, F
ENVIRONMENTAL STUDIES, 47, 36, 83, P
SYSTEM PROGRAMMING, 40, 36, 76, P
MICROPROCESSOR BASED DESIGN, 3, 35, 38, F
PROGRAMMING PARADIGMS, 42, 36, 78, P
COMMUNICATION SYSTEMS, 9, 35, 44, F
DATA STRUCTURE LAB, 10, 35, 45, F
PROGRAMMING ENVIRONMENTS LAB, 20, 25, 45, F