MyHTMLParser instance has no attribute 'intitle'
<p>I am trying to read title tags from HTML pages using HTMLParser. However I am getting the above error. My class looks like this:</p>

<p><em>readtitle.py</em></p>

<pre><code>from HTMLParser import HTMLParser
import urllib


class MyHTMLParser(HTMLParser):
    def __init__(self, url):
        HTMLParser.__init__(self)        
        self.url = url
        self.data = urllib.urlopen(url).read() 
        self.feed(self.data)
        self.intitle = ""
        self.mytitle = ""

    def handle_starttag(self, tag, attrs):
        self.intitle = tag == "title"

    def handle_data(self, data): 
        if self.intitle:
            self.mytitle = data
            return self.mytitle
</code></pre>

<p>I ran the code using the following commands and get the error:</p>

<pre><code>import urllib
import readtitle
parser = readtitle.MyHTMLParser("http://docs.python.org/tutorial/classes.html")

Traceback (most recent call last):
File "&lt;stdin&gt;", line 1, in &lt;module&gt;
File "readtitle.py", line 10, in __init__
 self.feed(self.data)
File "/usr/lib/python2.6/HTMLParser.py", line 108, in feed
 self.goahead(0)
File "/usr/lib/python2.6/HTMLParser.py", line 142, in goahead
 if i &lt; j: self.handle_data(rawdata[i:j])
File "readtitle.py", line 18, in handle_data
if self.intitle:
AttributeError: MyHTMLParser instance has no attribute 'intitle'
</code></pre>
