'commit'
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
# 采集配置
|
# 采集配置
|
||||||
SCROLL_DISTANCE_RATIO = 0.5
|
SCROLL_DISTANCE_RATIO = 0.5
|
||||||
MAX_STATIONS_COUNT = 30
|
MAX_STATIONS_COUNT = 1
|
||||||
FIRST_RUN_ONLY_ONE_STATION = False
|
FIRST_RUN_ONLY_ONE_STATION = False
|
||||||
REDIS_STATION_EXPIRE = 120
|
REDIS_STATION_EXPIRE = 120
|
||||||
DATA_RETENTION_DAYS = 365
|
DATA_RETENTION_DAYS = 365
|
||||||
|
|||||||
Binary file not shown.
@@ -317,42 +317,22 @@ async def get_station_list(d, service, uploader, max_stations_count=MAX_STATIONS
|
|||||||
entered_price_page = True
|
entered_price_page = True
|
||||||
price_screenshots = []
|
price_screenshots = []
|
||||||
|
|
||||||
# 1. 向下滚动到底 (根据用户反馈:只有不断向下滚动,才能看到00点的)
|
w, h = d.window_size()
|
||||||
logger.info("正在向下滚动价格列表到底部 (快速多次滚动以尽快看到 00:00)...")
|
scroll_x = int(w * 0.5)
|
||||||
max_scroll_down = 10
|
scroll_top_y = int(h * 0.6)
|
||||||
for i in range(max_scroll_down):
|
scroll_bottom_y = int(h * 0.85)
|
||||||
before_scroll_path = take_screenshot(d, f"scroll_dn_{i}", save_dir=TEMP_IMAGE_DIR)
|
|
||||||
before_scroll_md5 = Kit.get_image_content_md5(before_scroll_path)
|
|
||||||
|
|
||||||
d.swipe_ext("up", scale=0.8)
|
logger.info("从当前时段开始向下浏览价格列表并逐页截图...")
|
||||||
await asyncio.sleep(0.3)
|
|
||||||
|
|
||||||
after_scroll_path = take_screenshot(d, f"scroll_dn_after_{i}", save_dir=TEMP_IMAGE_DIR)
|
|
||||||
after_scroll_md5 = Kit.get_image_content_md5(after_scroll_path)
|
|
||||||
|
|
||||||
# 清理临时截图
|
|
||||||
if os.path.exists(before_scroll_path): os.remove(before_scroll_path)
|
|
||||||
if os.path.exists(after_scroll_path): os.remove(after_scroll_path)
|
|
||||||
|
|
||||||
if before_scroll_md5 == after_scroll_md5:
|
|
||||||
logger.info(f"价格列表已到达底部 (滚动次数: {i})")
|
|
||||||
break
|
|
||||||
|
|
||||||
# 2. 向上滚动并逐页截图 (从底向上抓取)
|
|
||||||
logger.info("正在向上滚动价格列表并逐页截图...")
|
|
||||||
max_scroll_up = 10
|
max_scroll_up = 10
|
||||||
for p_idx in range(1, max_scroll_up + 1):
|
for p_idx in range(1, max_scroll_up + 1):
|
||||||
# 截图当前页
|
|
||||||
p_uuid = f"{hashlib.md5(station_name.encode('utf-8')).hexdigest()}_p_{p_idx}"
|
p_uuid = f"{hashlib.md5(station_name.encode('utf-8')).hexdigest()}_p_{p_idx}"
|
||||||
p_path = take_screenshot(d, p_uuid, save_dir=TEMP_IMAGE_DIR)
|
p_path = take_screenshot(d, p_uuid, save_dir=TEMP_IMAGE_DIR)
|
||||||
price_screenshots.append(p_path)
|
price_screenshots.append(p_path)
|
||||||
|
|
||||||
# 检查是否还能向上滚动
|
|
||||||
before_up_md5 = Kit.get_image_content_md5(p_path)
|
before_up_md5 = Kit.get_image_content_md5(p_path)
|
||||||
d.swipe_ext("down", scale=0.85)
|
d.swipe(scroll_x, scroll_bottom_y, scroll_x, scroll_top_y, 0.2)
|
||||||
await asyncio.sleep(0.3)
|
await asyncio.sleep(0.3)
|
||||||
|
|
||||||
# 检查是否还有新内容
|
|
||||||
check_up_path = take_screenshot(d, f"check_up_{p_idx}", save_dir=TEMP_IMAGE_DIR)
|
check_up_path = take_screenshot(d, f"check_up_{p_idx}", save_dir=TEMP_IMAGE_DIR)
|
||||||
after_up_md5 = Kit.get_image_content_md5(check_up_path)
|
after_up_md5 = Kit.get_image_content_md5(check_up_path)
|
||||||
if os.path.exists(check_up_path): os.remove(check_up_path)
|
if os.path.exists(check_up_path): os.remove(check_up_path)
|
||||||
|
|||||||
@@ -57,13 +57,21 @@ async def check_and_close_ad(d):
|
|||||||
if ad_type == "rabbit":
|
if ad_type == "rabbit":
|
||||||
logger.info(">>> 检测到兔子广告。尝试使用图片识别关闭...")
|
logger.info(">>> 检测到兔子广告。尝试使用图片识别关闭...")
|
||||||
try:
|
try:
|
||||||
# 使用用户验证有效的图片点击方法
|
template_path_1 = os.path.join(BASE_DIR, "Template", "X1.jpg")
|
||||||
template_path = os.path.join(BASE_DIR, "Template", "X.jpg")
|
template_path_2 = os.path.join(BASE_DIR, "Template", "X2.jpg")
|
||||||
if d.image.click(template_path, timeout=3.0):
|
clicked = False
|
||||||
logger.info(">>> 成功通过图片识别关闭兔子广告。")
|
if d.image.click(template_path_1, timeout=3.0):
|
||||||
await asyncio.sleep(1.5)
|
logger.info(">>> 成功通过图片识别关闭兔子广告 (X1 模板)。")
|
||||||
|
clicked = True
|
||||||
else:
|
else:
|
||||||
logger.warning(">>> 图片识别未找到兔子广告关闭按钮,跳过。")
|
logger.warning(">>> X1 模板未找到兔子广告关闭按钮,尝试 X2 模板。")
|
||||||
|
if d.image.click(template_path_2, timeout=3.0):
|
||||||
|
logger.info(">>> 成功通过图片识别关闭兔子广告 (X2 模板)。")
|
||||||
|
clicked = True
|
||||||
|
else:
|
||||||
|
logger.warning(">>> X2 模板也未找到兔子广告关闭按钮。")
|
||||||
|
if clicked:
|
||||||
|
await asyncio.sleep(1.5)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logger.error(f">>> 图片识别关闭兔子广告异常: {ex}")
|
logger.error(f">>> 图片识别关闭兔子广告异常: {ex}")
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
BIN
Apps/XinDianTu/Template/X2.jpg
Normal file
BIN
Apps/XinDianTu/Template/X2.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 897 B |
Binary file not shown.
Binary file not shown.
@@ -2,4 +2,4 @@ import uiautomator2 as u2
|
|||||||
# pip install findit
|
# pip install findit
|
||||||
d = u2.connect()
|
d = u2.connect()
|
||||||
|
|
||||||
d.image.click("../Template/X.jpg")
|
d.image.click("../Template/X1.jpg")
|
||||||
Reference in New Issue
Block a user