'commit'
This commit is contained in:
BIN
Apps/YeLiTe/Config/__pycache__/Setting.cpython-310.pyc
Normal file
BIN
Apps/YeLiTe/Config/__pycache__/Setting.cpython-310.pyc
Normal file
Binary file not shown.
@@ -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")
|
||||
@@ -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
|
||||
@@ -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(
|
||||
@@ -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]
|
||||
|
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.7 KiB |
BIN
Apps/YeLiTe/__pycache__/Crawler.cpython-310.pyc
Normal file
BIN
Apps/YeLiTe/__pycache__/Crawler.cpython-310.pyc
Normal file
Binary file not shown.
BIN
Apps/YeLiTe/__pycache__/Kit.cpython-310.pyc
Normal file
BIN
Apps/YeLiTe/__pycache__/Kit.cpython-310.pyc
Normal file
Binary file not shown.
BIN
Apps/YeLiTe/__pycache__/Opener.cpython-310.pyc
Normal file
BIN
Apps/YeLiTe/__pycache__/Opener.cpython-310.pyc
Normal file
Binary file not shown.
BIN
Apps/YeLiTe/__pycache__/ReadImageKit.cpython-310.pyc
Normal file
BIN
Apps/YeLiTe/__pycache__/ReadImageKit.cpython-310.pyc
Normal file
Binary file not shown.
BIN
Apps/YeLiTe/__pycache__/Service.cpython-310.pyc
Normal file
BIN
Apps/YeLiTe/__pycache__/Service.cpython-310.pyc
Normal file
Binary file not shown.
BIN
Apps/YeLiTe/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
Apps/YeLiTe/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
@@ -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)
|
||||
BIN
Util/__pycache__/VLMKit.cpython-310.pyc
Normal file
BIN
Util/__pycache__/VLMKit.cpython-310.pyc
Normal file
Binary file not shown.
Reference in New Issue
Block a user