urllib2.URLError: <urlopen error unknown url type: 'http> error using twill with python

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Mon Jun 8 13:58:29 CEST 2009


On Mon, 08 Jun 2009 12:14:18 +0100, Mark Devine wrote:

> Hi
> I wonder if someone could point me in the right direction. I used the
> following code to access gmail but I got a
>          urllib2.URLError: <urlopen error unknown url type: 'http>
> error when I ran it. I have included the Traceback
> 
> import twill, string, os
> b=twill.commands.get_browser()
> b.set_agent_string("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB;
> rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14") b.clear_cookies()
> b.go('http://www.gmail.com')
> f=b.get_form("1")
> b.showforms()
> f['Email']= email
> f['Passwd'] =password
> b.clicked(f, f)
> b.submit()


My bet is that the above is not the actual code you have run. I bet that 
the offending line is actually something like the following:

b.go("'http://www.gmail.com")

Note that there is a single character difference.

Consider the last two lines of the traceback:

>     raise URLError('unknown url type: %s' % type)
> urllib2.URLError: <urlopen error unknown url type: 'http>


It seems to be saying that the url type is 'http -- note the leading 
single quote.


-- 
Steven



More information about the Python-list mailing list