File size: 1,012 Bytes
13df892
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from playwright.sync_api import sync_playwright

URL = "https://huggingface.co/hkblockchaintechnology/tiny-computer-agent"
with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page(viewport={"width": 1440, "height": 1100})
    page.goto(URL, wait_until="load", timeout=120000)
    page.wait_for_timeout(6000)
    html = page.content()
    print("len(html):", len(html))
    for needle in ["gallery/", "<img", "article img", "Capability gallery",
                   "desk-click", "resolve/main/gallery"]:
        print(f"  {needle!r:24} occurrences in DOM: {html.count(needle)}")
    print("total <img> on page:", page.eval_on_selector_all("img", "els => els.length"))
    print("containers:", page.eval_on_selector_all(
        "main, article, [class*=prose]", "els => els.slice(0,4).map(e => e.tagName + '.' + e.className.slice(0,40))"))
    # is the card text itself rendered?
    print("has heading text:", page.locator("text=Capability gallery").count())
    browser.close()