예제 #1
0
 def __init__(self):
     self.ANDROID_ID = '1234567890abcdef'
     self.email = account.user()
     self.password = account.password()
     self.api = Mobileclient()
     self.login()
     self.index = 0
     self.playQueue = []
예제 #2
0
def login():

    tn = telnetlib.Telnet(HOST)
    print 'connect ptt.cc'
    time.sleep(2)
    content = tn.read_very_eager().decode('big5','ignore')    #進站畫面   


    while '上方為使用者心情點播留言區,不代表本站立場' not in content.encode('utf-8'):

        while '系統過載' in content.encode('utf-8'):
            print('系統過載請稍候...')
            tn = telnetlib.Telnet('ptt.cc')
            content = tn.read_very_eager().decode('big5','ignore')
            time.sleep(2)


        if u"以 new 註冊:" in content:
            print 'username'
            username = account.username()
            tn.write((username+"\r\n").encode('big5'))
            time.sleep(1)
            
            print 'password'
            password = account.password()
            tn.write((password+"\r\n").encode('big5'))
            time.sleep(6)
            content = tn.read_very_eager().decode('big5','ignore')

 
        if u"密碼不對" in content:
            print("密碼不對或無此帳號。程式結束")
            sys.exit()

        if u"您想刪除其他重複登入的連線嗎" in content:
            print("發現重複連線,刪除他...")
            tn.write("Y\r\n".encode('big5')) 
            time.sleep(20)
            content = tn.read_very_eager().decode('big5','ignore')

        if u"任意鍵" in content:
            print("資訊頁面,按任意鍵繼續...")
            tn.write("\r\n".encode('big5'))
            time.sleep(2)
            content = tn.read_very_eager().decode('big5','ignore')

        if u'編輯器自動復原' in content:
            print('編輯器自動復原:不復原')
            tn.write("q\n".encode('big5'))
            time.sleep(2)
            content = tn.read_very_eager().decode('big5','ignore')

        if u'要刪除以上錯誤嘗試的記錄嗎' in content:
            print '刪除以上錯誤嘗試的記錄'
            print re.findall('[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+',content)
            tn.write("y\n".encode('big5'))
            time.sleep(2)
            content = tn.read_very_eager().decode('big5','ignore')

    print '登入成功'
    return tn