Python 使用 selenium 自动化登录 AppStore Connect 后台

环境配置

python3 环境为例

安装 selenium

pip3 install selenium

物料配置

Apple ID + 密码 + 此账号双重认证验证码

Python 示例脚本

下面是一个自动打开网页自动填充账号密码,选择第一个手机号发送验证码,以及收到验证码后在终端输入 6 位数验证码,回车确认即可登入成功。

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, "//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, "//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, "//button[@class='button button-rounded-rectangle']").click()


sleep(500)
dr.quit()

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容