Download screenshot.py from FincH12/Automation_Threads_EU: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/spaces/FincH12/Automation_Threads_EU/resolve/main/screenshot.py
- Command line
-
hf download hf://spaces/FincH12/Automation_Threads_EU/screenshot.py
-
curl -L -o screenshot.py https://huggingface.co/spaces/FincH12/Automation_Threads_EU/resolve/main/screenshot.py
1.07 kB
| import time | |
| import threading | |
| import http.server | |
| import socketserver | |
| import os | |
| from selenium import webdriver | |
| from selenium.webdriver.chrome.options import Options | |
| # Start local server | |
| def serve(): | |
| Handler = http.server.SimpleHTTPRequestHandler | |
| with socketserver.TCPServer(("", 8090), Handler) as httpd: | |
| httpd.serve_forever() | |
| server_thread = threading.Thread(target=serve, daemon=True) | |
| server_thread.start() | |
| time.sleep(1) # wait for server to start | |
| try: | |
| options = Options() | |
| options.add_argument('--headless') | |
| options.add_argument('--no-sandbox') | |
| options.add_argument('--disable-dev-shm-usage') | |
| options.add_argument('--window-size=1400,900') | |
| driver = webdriver.Chrome(options=options) | |
| driver.get('http://localhost:8090/dashboard.html') | |
| time.sleep(3) # Wait for animations and fetch (fetch will fail but UI will render) | |
| driver.save_screenshot('dashboard_preview.png') | |
| driver.quit() | |
| print('Screenshot saved as dashboard_preview.png') | |
| except Exception as e: | |
| print(f'Error taking screenshot: {e}') | |