This commit is contained in:
HuangHai
2026-01-13 20:46:18 +08:00
parent b3a2bd4816
commit 6a11893d07
17 changed files with 49 additions and 19 deletions

Binary file not shown.

View File

@@ -6,10 +6,10 @@ import sys
import json
import time
from datetime import datetime
from Apps.YiLaiTe.Kit import take_screenshot, clean_station_name, get_image_content_md5
from Apps.YiLaiTe.ReadImageKit import ReadImageKit
from Apps.YiLaiTe.Service import YiLaiTeService
from Apps.YiLaiTe.Config.Setting import (
from Apps.YeLiTe.Kit import take_screenshot, clean_station_name, get_image_content_md5
from Apps.YeLiTe.ReadImageKit import ReadImageKit
from Apps.YeLiTe.Service import YiLaiTeService
from Apps.YeLiTe.Config.Setting import (
SCROLL_DISTANCE_RATIO, WAIT_AFTER_SCROLL, MAX_STATIONS_COUNT,
WAIT_DETAIL_PAGE_LOAD, WAIT_BACK_TO_LIST, TEST_CLEAR_REDIS,
SAFE_EXCLUDE_RATIO, BOTTOM_SAFE_EXCLUDE_RATIO
@@ -34,10 +34,30 @@ class YiLaiTeCrawler(BaseCrawler):
async def start(self):
"""
启动入口
实现 BaseCrawler 启动入口
"""
await main(self.service)
async def open_app(self):
"""
打开驿来特小程序
"""
from Apps.YeLiTe import Opener
return await Opener.open_mini_program()
async def crawl_list(self):
"""
开始爬取列表页
"""
d = u2.connect()
return await self.crawl_list_logic(d)
async def crawl_detail(self, station_info):
"""
爬取详情页 (BaseCrawler 要求此处逻辑已集成在 crawl_list_logic )
"""
pass
async def clean_redis_data(self):
"""
清除测试用的 Redis 记录
@@ -109,7 +129,7 @@ class YiLaiTeCrawler(BaseCrawler):
processed_count += 1
new_stations_in_page += 1
await self.redis_kit.set_data(redis_key, "1", ex=86400*7)
await self.redis_kit.set_data(redis_key, "1", expire=86400*7)
# 返回
d.press("back")

View File

@@ -18,18 +18,22 @@ def clean_station_name(name):
name = re.sub(r'.*?', '', name)
return name.strip()
def take_screenshot(d, filename, path=None):
def take_screenshot(d, filename, save_dir=None):
"""
获取屏幕截图并保存
"""
if not path:
if not save_dir:
from Config.Config import TEMP_IMAGE_DIR
path = TEMP_IMAGE_DIR
save_dir = TEMP_IMAGE_DIR
if not os.path.exists(path):
os.makedirs(path)
if not os.path.exists(save_dir):
os.makedirs(save_dir)
full_path = os.path.join(path, filename)
# 确保文件名有后缀
if not filename.endswith(".jpg") and not filename.endswith(".png"):
filename = f"{filename}.jpg"
full_path = os.path.join(save_dir, filename)
d.screenshot(full_path)
return full_path
@@ -132,7 +136,7 @@ def draw_rectangles(image_path, points, output_path=None):
try:
import cv2
import numpy as np
from Config.Setting import DRAW_DEBUG_BOXES, DEBUG_BOX_COLOR, DEBUG_BOX_THICKNESS
from Apps.YeLiTe.Config.Setting import DRAW_DEBUG_BOXES, DEBUG_BOX_COLOR, DEBUG_BOX_THICKNESS
if not DRAW_DEBUG_BOXES:
return image_path

View File

@@ -5,8 +5,8 @@ import os
import time
import uiautomator2 as u2
import uuid
from Apps.YiLaiTe.Kit import take_screenshot
from Apps.YiLaiTe.ReadImageKit import ReadImageKit
from Apps.YeLiTe.Kit import take_screenshot
from Apps.YeLiTe.ReadImageKit import ReadImageKit
from Config.Config import TEMP_IMAGE_DIR
logging.basicConfig(

View File

@@ -12,8 +12,8 @@ from Util.VLMKit import VLMKit
import json
import re
from Apps.YiLaiTe.Kit import draw_rectangles
from Apps.YiLaiTe.Config.Setting import DRAW_DEBUG_BOXES
from Apps.YeLiTe.Kit import draw_rectangles
from Apps.YeLiTe.Config.Setting import DRAW_DEBUG_BOXES
logger = logging.getLogger(__name__)
@@ -61,6 +61,12 @@ class ReadImageKit:
"""
prompt = """
分析这张充电站列表截图提取所有充电站卡片信息
**重要过滤规则**
1. 忽略顶部的筛选栏排序方式区域包含排序方式离我最近地图模式停车收费限时免费等按钮的区域
2. 仅提取下方重复出现的场站信息卡片
3. 场站卡片通常包含场站名称驿来特...价格¥1.33//慢充桩数量距离等
输出格式为 JSON 数组每个对象包含
- "name": 场站名称
- "point": 场站卡片的中心点击坐标 [x, y]

View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -17,8 +17,8 @@ logging.basicConfig(
logger = logging.getLogger("T3_YiLaiTe")
try:
from Apps.YiLaiTe.Service import YiLaiTeService
from Apps.YiLaiTe import Opener, Crawler, Kit
from Apps.YeLiTe.Service import YiLaiTeService
from Apps.YeLiTe import Opener, Crawler, Kit
except KeyboardInterrupt:
logger.info("\n🛑 用户在初始化阶段手动停止了程序。")
sys.exit(0)

Binary file not shown.