views:

97

answers:

3

for the following code

theurl = "https://%s:%[email protected]/nic/update?hostname=%s&myip=%s&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG" % (username, password, hostname, theip)

conn = urlopen(theurl) # send the request to the url
print(conn.read())  # read the response
conn.close()   # close the connection

i get the following error

File "c:\Python31\lib\http\client.py", line 667, in _set_hostport
    raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])

Any Ideas???

A: 

The error message shows that there is some issue with the url that you are preparing. Print and check if this is a valid url.

anand
Why print it? He's posted it in the question. The issue is the `:` in the URL which muckabout has mentioned.
Noufal Ibrahim
+1  A: 

The ':' in the HTTP URL is assumed to precede a port number. You are placing an account name which is not numeric. It must be an integer port value.

muckabout
In addition, you should see if they have a web based API which you can use programmatically.
Noufal Ibrahim
+1  A: 

I agree with muckabout, this is the problem. You're probably used to using this in a browser, which would cause the browser to authenticate with the host. You should probably drop everything before the first @ sign.

have a look at urllib docs, specifically FancyURLOpener which might resolve your issue with authentication.

Yoni H