chenzehe
# -*- coding:UTF-8 -*- 
#
!/user/bin/env python
\'\'\'
Created on 2010-9-1
@author: chenzehe
\'\'\'
import win32com.client
from time import sleep

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.ReadyState    
print "打开登陆页面"    
while 1:    
    state 
= ie.ReadyState    
    
if state ==4:    
        
break    
    sleep(
1)
print "页面载入完毕,输入用户名密码"    
state 
= None

ie.Document.getElementById(
"tbUserName").value=username    
ie.Document.getElementById(
"tbPassword").value=password    
ie.Document.getElementById(
"btnLogin").click()   


while 1:    
    state 
= ie.ReadyState    
    
print state    
    
if state ==4 and str(ie.LocationURL) == "http://home.cnblogs.com/":    
        
break
    sleep(
1)
print "登陆成功" 
print \'你的昵称是:\'
print ie.Document.getElementById(\'lnk_current_user\').title

#博客园只能登录一次,注销
print \'注销!\'
ie.Navigate(loginouturl)


 

分类:

技术点:

相关文章:

  • 2021-11-02
  • 2021-09-19
  • 2021-11-02
  • 2022-02-19
  • 2021-08-30
  • 2022-02-26
猜你喜欢
  • 2021-12-12
  • 2022-12-23
  • 2022-01-21
  • 2021-11-27
  • 2022-02-05
相关资源
相似解决方案