Got the starttag working as a global variable
This commit is contained in:
1 parent
d11087907d
commit
4865e04986
1 file changed
+8
-2
@@ -6,8 +6,14 @@ starttag = ""
|
||||
|
||||
class MyHTMLParser(HTMLParser):
|
||||
def handle_starttag(self, tag, attrs):
|
||||
global starttag
|
||||
starttag = tag
|
||||
print starttag
|
||||
#print starttag
|
||||
def handle_data(self, data):
|
||||
#print starttag
|
||||
if starttag == "code":
|
||||
print data
|
||||
pass
|
||||
|
||||
|
||||
conn = httplib.HTTPSConnection("www.python.org")
|
||||
@@ -15,4 +21,4 @@ conn.request("GET", "/")
|
||||
r1 = conn.getresponse()
|
||||
parser = MyHTMLParser()
|
||||
|
||||
parser.feed(r1.read())
|
||||
parser.feed(r1.read())
|
||||
Reference in new issue
Block a user