First time working with the HTMLParser module. Trying to use standard string formatting on the ouput, but it's giving me an error. The following code:
import urllib2
from HTMLParser import HTMLParser
class LinksParser(HTMLParser):
def __init__(self, url):
HTMLParser.__init__(self)
req = urllib2.urlopen(url)
self.feed(req.read())
def handle_starttag(self, tag, attrs):
if tag != 'a': return
for name, value in attrs:
print("Found Link --> {]".format(value))
if __name__ == "__main__":
LinksParser("http://www.facebook.com"
Produces the following error:
File "C:\Users\workspace\test\src\test.py", line 15, in handle_starttag
print("Found Link --> {]".format(value))
ValueError: unmatched '{' in format