#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""抓取天隆看板新增注解相关区域截图，供目视验收。"""
import os
from playwright.sync_api import sync_playwright

HTML = os.path.abspath('工具/天隆_2025vs2026_趋势看板.html')
SHOT = '/Users/liuxinyuan/.hermes/profiles/zone-b/cache/scratch/tianlong_notes'
os.makedirs(SHOT, exist_ok=True)

with sync_playwright() as p:
    b = p.chromium.launch(channel='chrome')
    pg = b.new_page(viewport={'width': 1440, 'height': 1000}, device_scale_factor=2)
    pg.goto('file://' + HTML)
    pg.wait_for_load_state('load')
    pg.wait_for_timeout(700)
    pg.query_selector('#blk5').screenshot(path=os.path.join(SHOT, '10_业务注解块.png'))
    pg.query_selector('#blk2').screenshot(path=os.path.join(SHOT, '11_卡片角标.png'))
    pg.query_selector('#blk4').screenshot(path=os.path.join(SHOT, '12_结构带角标.png'))
    pg.query_selector('.concl').screenshot(path=os.path.join(SHOT, '13_结论条.png'))
    from PIL import Image
    for f in sorted(os.listdir(SHOT)):
        im = Image.open(os.path.join(SHOT, f))
        print(f, im.size)
    b.close()
