TypeError: expected BaseHandler instance, got <type 'str'>
<pre><code>import urllib2, re, urllib

def login():
    host = "http://localhost/cms/"
    user = 'admin'
    passw = 'admin'
    error = "Login to CMS Made Simple"
    form = [
        ('username', user),
        ('password', word)]   
    target = host + "/admin/login.php"
    login_form_data = urllib.urlencode(form)
    opener = urllib2.build_opener(target)
    opener.addheaders = [('User-agent', 'Mozilla/5.0')]
    source = opener.open(target, login_form_data).read()
    if re.search(error, source) == None : 
        print 'FOund =&gt;&gt;&gt;' + target + 'Username : ' + user + 'Password :  ' + word
    else: 
        print 'Not Found=&gt;&gt; ' + target + '  Username : ' + user + 'Password :  ' + word

login()
</code></pre>

<p>I'm getting this:</p>

<pre><code>    opener = urllib2.build_opener(host)
  File "D:\Python27\lib\urllib2.py", line 486, in build_opener
    opener.add_handler(h)
  File "D:\Python27\lib\urllib2.py", line 322, in add_handler
    type(handler))
TypeError: expected BaseHandler instance, got &lt;type 'str'&gt;
</code></pre>

<p>I think the problem is here: <code>opener = urllib2.build_opener(target)</code></p>

<p>But how to solve it? I tried a lot.</p>
