You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.8 KiB
42 lines
1.8 KiB
# -*- coding: utf-8 -*-
|
|
"""查 head 原文 + 浏览器 styleSheets 加载情况"""
|
|
import io, sys, time
|
|
from pathlib import Path
|
|
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
|
|
|
P = Path(r'e:\code\crm-backend-matt\.scratch\a7-parity\pages\a7-3-1_线索规则')
|
|
h = (P / 'a7-3-1_线索规则.html').read_text(encoding='utf-8', errors='replace')
|
|
head = h[:h.find('</head>') + 7]
|
|
print('=== raw <link lines in head ===')
|
|
for line in head.splitlines():
|
|
if 'link' in line.lower() or 'stylesheet' in line.lower():
|
|
print(line.strip()[:200])
|
|
|
|
html_path = P / 'a7-3-1_线索规则.html'
|
|
url = 'file:///' + str(html_path).replace('\\', '/')
|
|
from playwright.sync_api import sync_playwright
|
|
with sync_playwright() as p:
|
|
browser = p.chromium.launch()
|
|
ctx = browser.new_context(viewport={'width': 1600, 'height': 900})
|
|
ctx.add_init_script("window.lanhu_Axure_Mapping_Data = function(d){ return d; };")
|
|
page = ctx.new_page()
|
|
page.goto(url, wait_until='domcontentloaded', timeout=20000)
|
|
time.sleep(2)
|
|
info = page.evaluate("""() => ({
|
|
sheets: [...document.styleSheets].map(s => {
|
|
let n = -1; try { n = s.cssRules.length } catch(e) { n = 'ERR:' + e.message }
|
|
return {href: (s.href||'inline').split('/').pop(), rules: n};
|
|
}),
|
|
u3: (() => { const el = document.getElementById('u3');
|
|
if (!el) return 'no u3';
|
|
const cs = getComputedStyle(el);
|
|
return {pos: cs.position, left: cs.left, top: cs.top, w: cs.width, h: cs.height}; })(),
|
|
u3img: (() => { const el = document.getElementById('u3_img');
|
|
if (!el) return 'none';
|
|
const cs = getComputedStyle(el);
|
|
return {w: cs.width, h: cs.height, display: cs.display, src: el.src.slice(-30)}; })(),
|
|
})""")
|
|
for k, v in info.items():
|
|
print(k, ':', v)
|
|
browser.close()
|
|
|