Created
December 16, 2013 05:15
-
-
Save studiawan/7982630 to your computer and use it in GitHub Desktop.
HTTP client using urllib2 and native HTMLParser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from HTMLParser import HTMLParser | |
import urllib2 | |
class MyHTMLParser(HTMLParser): | |
def handle_starttag(self, tag, attrs): | |
print "Encountered a start tag:", tag | |
def handle_endtag(self, tag): | |
print "Encountered an end tag :", tag | |
def handle_data(self, data): | |
print "Encountered some data :", data | |
parser = MyHTMLParser() | |
response = urllib2.urlopen('http://www.studiawan.com').read() | |
parser.feed(response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment