main
HuangHai 5 months ago
parent 7158dfcb3a
commit 65465f8249

@ -5,6 +5,7 @@ https://ww1.colorlightcloud.com
项目:充电站 项目:充电站
分配空间4G 分配空间4G
pip install "numpy<2"
pip install playwright pip install playwright
playwright install playwright install
playwright codegen https://ww1.colorlightcloud.com playwright codegen https://ww1.colorlightcloud.com

@ -13,7 +13,6 @@ def run(playwright: Playwright) -> None:
# 打开登录页面 # 打开登录页面
print("打开登录页面...") print("打开登录页面...")
page.goto("https://ww1.colorlightcloud.com/login", wait_until="domcontentloaded") # 等待 DOM 加载完成 page.goto("https://ww1.colorlightcloud.com/login", wait_until="domcontentloaded") # 等待 DOM 加载完成
time.sleep(2) # 等待 2 秒,确保页面完全加载
# 输入用户名 # 输入用户名
print("输入用户名...") print("输入用户名...")
@ -33,34 +32,23 @@ def run(playwright: Playwright) -> None:
# 等待登录成功 # 等待登录成功
print("等待登录成功...") print("等待登录成功...")
page.wait_for_url("https://ww1.colorlightcloud.com/home", timeout=60000) # 等待跳转到 home 页面 page.wait_for_url("https://ww1.colorlightcloud.com/home", timeout=60000) # 等待跳转到 home 页面
time.sleep(2) # 等待 2 秒,确保页面完全加载
# 点击“媒体库” # 点击“媒体库”
print("点击媒体库...") print("点击媒体库...")
media_library = page.get_by_text("媒体库") # 通过 text 定位媒体库 media_library = page.get_by_text("媒体库") # 通过 text 定位媒体库
media_library.click() media_library.click()
time.sleep(1) # 等待 2 秒,确保页面完全加载
# 点击“上传”按钮 # 点击“上传”按钮
print("点击上传按钮...") print("点击上传按钮...")
upload_button = page.get_by_text("上传") # 通过 text 定位上传按钮 upload_button = page.get_by_text("上传") # 通过 text 定位上传按钮
upload_button.click() upload_button.click()
# 上传文件 print("触发文件选择对话框...")
page.locator("img").click() with page.expect_file_chooser() as fc_info:
# 等待文件选择对话框弹出 page.locator("img").click() # 触发文件选择对话框
time.sleep(1) # 根据实际情况调整等待时间 file_chooser = fc_info.value
print("切换为英文输入法...") file_chooser.set_files(r"d:\1.mp4") # 设置文件路径
pyautogui.press("capslock") time.sleep(15) # 等待上传完成
# 输入文件路径并按下回车键
print("输入文件路径并按下回车键...")
# 逐个输入字符
for char in r"d:\1.mp4":
pyautogui.press(char)
pyautogui.press("capslock")
pyautogui.press("enter")
time.sleep(50)
except Exception as e: except Exception as e:
print(f"操作过程中发生错误: {e}") print(f"操作过程中发生错误: {e}")

Loading…
Cancel
Save