My python auto-login script is broken.

Posted by user310392 on Stack Overflow See other posts from Stack Overflow or by user310392
Published on 2010-04-06T21:07:17Z Indexed on 2010/04/06 21:23 UTC
Read the original article Hit count: 388

Filed under:
|
|

A long time ago, I wrote a little python script to automatically log me on to the wireless network at my office.

Here is the code:

#!/opt/local/bin/python
from urllib2 import urlopen
from ClientForm import ParseResponse

try:
if "Logged on as" in urlopen("https://MYWIRELESS.com/logon").read():
    print "Already logged on."
else:
    forms = ParseResponse(urlopen("https://MYWIRELESS.com/logon"), backwards_compat=False)
    form = forms[0]
    form["username"], form["password"] = "ME", "MYPASSWD"
    urlopen(form.click())
    print "Logged on. (probably :-)";
except IOError, e: print "Couldn't connect to wireless login page:\n", e

I changed computers recently, and it stopped working. Now, I get the error:

File "login.txt", line 4, in <module>
    from ClientForm import ParseResponse
ImportError: No module named ClientForm

which makes it look like I don't have some package (ClientForm) installed, so I installed it (sudo port install py-clientform), but I still get the same error. Does anyone have an idea what I'm doing wrong?

© Stack Overflow or respective owner

Related posts about python

Related posts about login