環(huán)境配置
以 python3
環(huán)境為例
安裝 selenium
pip3 install selenium
物料配置
Apple ID + 密碼 + 此賬號雙重認證驗證碼
Python 示例腳本
下面是一個自動打開網(wǎng)頁自動填充賬號密碼腻格,選擇第一個手機號發(fā)送驗證碼画拾,以及收到驗證碼后在終端輸入 6 位數(shù)驗證碼,回車確認即可登入成功菜职。
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
dr = webdriver.Chrome()
dr.get('https://appstoreconnect.apple.com/login')
dr.implicitly_wait(60)
dr.switch_to.frame('aid-auth-widget-iFrame')
dr.find_element(By.ID, 'account_name_text_field').send_keys('輸入你的apple id')
sleep(1)
dr.find_element(By.ID, 'sign-in').click()
sleep(2)
dr.find_element(By.ID, 'password_text_field').send_keys('輸入你的密碼')
sleep(1)
dr.find_element(By.ID, 'sign-in').click()
sleep(1)
# 選擇手機號
ul_div = dr.find_element(By.XPATH, "http://ul[@class='container si-field-container si-device-container ']")
# 收集手機號列表
phone_list = ul_div.find_elements(By.TAG_NAME, 'li')
# 默認點擊第一個號碼
phone_list[0].click()
sleep(5)
# form-security-code-inputs
text_div = dr.find_element(By.XPATH, "http://div[@class='form-security-code-inputs']")
text_list = text_div.find_elements(By.TAG_NAME, 'input')
print(len(text_list))
user_input = input('請輸入驗證碼:')
text_list[0].send_keys(user_input[0])
text_list[1].send_keys(user_input[1])
text_list[2].send_keys(user_input[2])
text_list[3].send_keys(user_input[3])
text_list[4].send_keys(user_input[4])
text_list[5].send_keys(user_input[5])
dr.find_element(By.XPATH, "http://button[@class='button button-rounded-rectangle']").click()
sleep(500)
dr.quit()