feat: add automation scripts, XML parsing logic for UI element identification, and supplementary asset images

This commit is contained in:
Victor Phan
2026-07-21 09:56:12 +07:00
parent 749a30735e
commit 97ddcd2699
8 changed files with 109 additions and 89 deletions
+16 -26
View File
@@ -1,28 +1,18 @@
import uiautomator2 as u2
import time
from automation import ShopeeBot
# Kết nối điện thoại
d = u2.connect('10.160.138.2:5555')
link = "https://vn.shp.ee/tZVnqovi"
print("Đang bật sáng màn hình...")
d.screen_on()
# d.unlock() # Bỏ comment dòng này nếu máy bạn có màn hình khóa vuốt (không mật khẩu)
time.sleep(1)
print("🚀 Đang bắn lệnh ép Shopee mở thẳng sản phẩm...")
# Lệnh ADB này ép Android mở link trực tiếp bằng app Shopee
d.shell(f'am start -a android.intent.action.VIEW -d "{link}"')
# Chờ 8 giây để app load xong hình ảnh và thông tin (mạng chậm thì tăng lên)
print("⏳ Đang đợi Shopee tải trang...")
time.sleep(8)
print("🔍 Đang quét cấu trúc màn hình hiện tại...")
xml_dump = d.dump_hierarchy()
# Xuất toàn bộ giao diện màn hình ra một file XML để chúng ta "soi"
with open("ui_dump.xml", "w", encoding="utf-8") as f:
f.write(xml_dump)
print("✅ Đã xuất giao diện ra file 'ui_dump.xml'.")
if __name__ == "__main__":
# Thay thế bằng IP của điện thoại trong mạng (lấy từ lệnh adb devices)
DEVICE_IP = '10.160.138.2:5555'
bot = ShopeeBot(DEVICE_IP)
test_url = "https://vn.shp.ee/tZVnqovi"
print(f"\n[BẮT ĐẦU] Lấy hoa hồng cho link: {test_url}")
# Đoạn này sẽ chạy đúng quy trình: Mở Shopee -> Tôi -> Tiếp Thị Liên Kết -> Chuyển Đổi
result = bot.get_commission_rate(test_url)
print("\n===============================")
print(f"🎯 KẾT QUẢ: {result}")
print("===============================\n")