很久以前,我写了一个小python脚本来自动登录我办公室的无线网络。
这是代码:
#!/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
我最近换了电脑,它停止工作。现在,我得到了错误:
File "login.txt", line 4, in <module>
from ClientForm import ParseResponse
ImportError: No module named ClientForm
这让我看起来好像没有安装一些包(ClientForm),所以我安装了它(sudo port install py-clientform),但我仍然得到同样的错误。有谁知道我做错了什么?