Download code/shot2.py from eduzrh/helloworld: direct link, hf CLI and curl.
- Browser
- Download file 767 Bytes
-
https://huggingface.co/datasets/eduzrh/helloworld/resolve/main/code/shot2.py
- Command line
-
hf download hf://datasets/eduzrh/helloworld/code/shot2.py
-
curl -L -o shot2.py https://huggingface.co/datasets/eduzrh/helloworld/resolve/main/code/shot2.py
767 Bytes
| from playwright.sync_api import sync_playwright | |
| import pathlib, sys | |
| f = sys.argv[1] if len(sys.argv) > 1 else "demo/cdhe-monitor.html" | |
| out = sys.argv[2] if len(sys.argv) > 2 else "figures/demo.png" | |
| w, h = (int(sys.argv[3]), int(sys.argv[4])) if len(sys.argv) > 4 else (1600, 920) | |
| url = "file://" + str(pathlib.Path(f).resolve()) | |
| with sync_playwright() as p: | |
| b = p.chromium.launch() | |
| pg = b.new_page(viewport={"width": w, "height": h}, device_scale_factor=2) | |
| errs = [] | |
| pg.on("console", lambda m: errs.append(f"{m.type}: {m.text}") if m.type == "error" else None) | |
| pg.on("pageerror", lambda e: errs.append("pageerror: " + str(e))) | |
| pg.goto(url) | |
| pg.wait_for_timeout(1200) | |
| pg.screenshot(path=out) | |
| print("errors:", errs[:5]) | |
| b.close() | |