25 lines
1.2 KiB
Python
25 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
import io, sys
|
|
from playwright.sync_api import sync_playwright
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
|
with sync_playwright() as p:
|
|
b = p.chromium.launch(channel='chrome', headless=True)
|
|
page = b.new_page(viewport={'width': 1500, 'height': 950})
|
|
page.goto('http://localhost:8088', wait_until='domcontentloaded'); page.wait_for_timeout(2500)
|
|
if 'login' in page.url:
|
|
page.locator('input[placeholder="用户名"]').fill('admin')
|
|
page.locator('input[placeholder="密码"]').fill('123456')
|
|
page.locator('text="登录"').first.click(); page.wait_for_timeout(6000)
|
|
page.goto('http://localhost:8088/#/product-story-info/9130', wait_until='domcontentloaded')
|
|
page.wait_for_timeout(6000)
|
|
info = page.evaluate("""() => {
|
|
const items = [...document.querySelectorAll('.filterInfo .el-tabs__item')];
|
|
return items.map(el => {
|
|
const cs = getComputedStyle(el);
|
|
const r = el.getBoundingClientRect();
|
|
return {text: el.innerText, padding: cs.padding, margin: cs.margin, x: Math.round(r.x), w: Math.round(r.width)};
|
|
});
|
|
}""")
|
|
for it in info: print(it)
|
|
b.close()
|