This commit is contained in:
HuangHai
2026-01-15 21:02:40 +08:00
parent e02a96642d
commit f1bb71b856
5 changed files with 34 additions and 9 deletions

View File

@@ -1,7 +1,7 @@
# 采集配置
SCROLL_DISTANCE_RATIO = 0.5
MAX_STATIONS_COUNT = 100
MAX_STATIONS_COUNT = 10
FIRST_RUN_ONLY_ONE_STATION = False
REDIS_STATION_EXPIRE = 120
DATA_RETENTION_DAYS = 365

View File

@@ -68,19 +68,44 @@ async def open_mini_program():
d.app_start("com.tencent.mm", stop=True)
await asyncio.sleep(5)
# 2. 确保在消息列表页并点击搜索
logger.info("直接使用坐标点击 '搜索按钮' (84%, 8%)...")
# 2. 确保在“微信”消息列表标签页
tab_chat = d(text="微信", resourceId="com.tencent.mm:id/f2s")
if not tab_chat.exists:
tab_chat = d(text="微信")
if tab_chat.exists:
logger.info("点击底部‘微信’标签,确保在消息列表页.")
tab_chat.click()
await asyncio.sleep(1)
# 3. 点击搜索按钮(放大镜图标)
logger.info("直接使用百分比坐标点击 '搜索按钮' (84%, 8%)...")
w, h = d.window_size()
d.click(int(w * 0.84), int(h * 0.08))
click_x = int(w * 0.84)
click_y = int(h * 0.08)
d.click(click_x, click_y)
logger.info(f"使用精确坐标点击搜索按钮: ({click_x}, {click_y})")
await asyncio.sleep(2)
# 3. 输入搜索内容
# 4. 输入搜索内容
logger.info("输入搜索内容: 艾特吉易充")
d.send_keys("艾特吉易充")
try:
logger.info("尝试输入文字: 艾特吉易充")
d.send_keys("艾特吉易充")
logger.info("文字输入指令已发送.")
except Exception as e:
logger.warning(f"直接 send_keys 失败: {e}")
try:
logger.info("尝试使用 set_text 设置文本...")
d(focused=True).set_text("艾特吉易充")
logger.info("set_text 指令已发送.")
except Exception as e2:
logger.error(f"文字输入彻底失败: {e2}")
await asyncio.sleep(3)
# 4. 点击小程序
# 5. 点击小程序
logger.info("点击搜索结果中的小程序...")
# 这里由于没有模板,先使用坐标点击作为第一版的测试逻辑 (通常第一个结果在 50%, 18%)
# 后续有了截图后再补充模板匹配
@@ -90,7 +115,7 @@ async def open_mini_program():
await asyncio.sleep(8)
# 5. 进入后的广告检测 (只在进入时执行一次)
# 6. 进入后的广告检测 (只在进入时执行一次)
await check_and_close_ad(d)
return True

View File