import urllib
from urllib.request import urlopen
address='http://www.iitb.ac.in/acadpublic/RunningCourses.jsp?deptcd=EE&year=2012&semester=1'
source= urlopen(address).read()
source=str(source)
from html.parser import HTMLParser
class MyHTMLParser(HTMLParser):
def handle_data(self, data):
x=str(data)
if x != ('\r\n\t\t\t\t') or ('\r\n\t\t\t\t\t') or ('\r\n\r\n\t\t\t'):
print("Encountered some data:",x)
parser = MyHTMLParser(strict=False)
parser.feed(source)
上面的代码不起作用。它仍在打印 '\r\n\t\t\t\t' 的东西。有什么建议么?