#-*- coding:UTF-8 -*-#!/user/bin/env python'''Created on 2010-9-1
@author: chenzehe'''importwin32com.clientfromtimeimportsleep
loginurl='http://passport.cnblogs.com/login.aspx'loginouturl='http://passport.cnblogs.com/logout.aspx'username='XXX'password='XXX'ie=win32com.client.Dispatch("InternetExplorer.Application")
ie.Visible=0
ie.Navigate(loginurl)
state=ie.ReadyStateprint"打开登陆页面"while1:
state=ie.ReadyStateifstate==4:breaksleep(1)print"页面载入完毕,输入用户名密码"state=None
ie.Document.getElementById("tbUserName").value=username
ie.Document.getElementById("tbPassword").value=password
ie.Document.getElementById("btnLogin").click()while1:
state=ie.ReadyStateprintstateifstate==4andstr(ie.LocationURL)=="http://home.cnblogs.com/":breaksleep(1)print"登陆成功"print'你的昵称是:'printie.Document.getElementById('lnk_current_user').title#博客园只能登录一次,注销print'注销!'ie.Navigate(loginouturl)