Get username and password for sina weibo

#-*- coding: gb2312 -*-

from win32com.client import Dispatch as DSP
from PAM30 import PAMIE as PIE

cls_id = '{9BA05972-F6A8-11CF-A442-00A0C90A8F39}'

# find and attach the open IE
def get_cur_ie():
    wins = DSP(cls_id)
    for win in wins:
        if 'weibo.com' in win.locationURL:
            #print win.locationURL
            ie = PIE(cur_ie=win)
            return ie
    return None
#-- get_cur_ie --


# get the username and password
def get_info():
    ie = get_cur_ie()
    usr = ie.getTextBoxValue('loginname', 'value')
    psw = ie.getTextBoxValue('password', 'value')
    print 'Username: <%s>, Password: <%s>' % (usr, psw)
    pass
#-- get_info --


# the main function entry
if __name__ == '__main__':
    get_info()
    pass
#-- main --

你可能感兴趣的:(Get username and password for sina weibo)