File size: 1,129 Bytes
13df892
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""Screenshot the live model card page, including the gallery."""

from pathlib import Path

from playwright.sync_api import sync_playwright

URL = "https://huggingface.co/hkblockchaintechnology/tiny-computer-agent"
OUT = Path("preview")
OUT.mkdir(exist_ok=True)

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page(viewport={"width": 1440, "height": 1080})
    page.goto(URL, wait_until="load", timeout=120000)
    page.wait_for_timeout(6000)
    page.screenshot(path=str(OUT / "01-top.png"))

    # walk down the card so every lazy image is fetched, then shoot each band
    heading = page.locator("h2:has-text('Capability gallery')").first
    heading.scroll_into_view_if_needed(timeout=25000)
    page.wait_for_timeout(4000)
    page.screenshot(path=str(OUT / "02-gallery-head.png"))
    for index, step in enumerate([1400, 1500, 1600, 3000, 3000], start=3):
        page.mouse.wheel(0, step)
        page.wait_for_timeout(2200)
        page.screenshot(path=str(OUT / f"{index:02d}-gallery.png"))
    print("shot bands:", len(list(OUT.glob("*.png"))))
    browser.close()
print("done")