selenium 等待完成人工登錄(原創)


作者:漢學 

原創作品,轉載請保留出處 www.cnblogs.com/c2soft

 

使用selenium時,不少登錄操作需要識別驗證碼,這部分操作可以交給人工完成,待人工操作完成后再由 selenium 接管自動操作。

 

from selenium import webdriver

WEB_TITLE = "我的百度網盤"

wb = webdriver.Chrome()
wb.get("https://pan.baidu.com")

wait_flag = 1
while(wait_flag):
    handles = wb.window_handles  # 獲取當前窗口句柄集合(列表類型)
    # 逐個窗口打印標題
    for b in handles:
        wb.switch_to_window(b)

        #h_id = handles.index(b)
        #wb.switch_to_window(handles[h_id])

        if wb.title == WEB_TITLE:
            wait_flag = 0
            break

        #print(str(handels.index(b)) + " : " + wb.title + ": " + wb.current_url)
        print("等待打開登錄后的頁面...")
        time.sleep(5)


while(1):
    delay = random.randint(5, 11)
    time.sleep(delay)
    if checkFile(wb) == True:
        #os.system("tip.mp3")
        break
print("腳本執行完畢")

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM