mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 04:42:57 +00:00
example
This commit is contained in:
1 parent
85e24beabf
commit
c6e7a64e73
888 files changed
+251050
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import sys
|
||||
import time
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
def run():
|
||||
with sync_playwright() as p:
|
||||
# Launch browser (headless by default)
|
||||
browser = p.chromium.launch()
|
||||
page = browser.new_page()
|
||||
|
||||
# Capture console messages
|
||||
page.on("console", lambda msg: print(f"console:{msg.type}: {msg.text}"))
|
||||
|
||||
# Capture uncaught exceptions
|
||||
page.on("pageerror", lambda exc: print(f"pageerror: {exc}"))
|
||||
|
||||
# Capture failed requests
|
||||
page.on("requestfailed", lambda request: print(f"requestfailed: {request.url} {request.failure}"))
|
||||
|
||||
try:
|
||||
print("Navigating to http://localhost:8000...")
|
||||
page.goto("http://localhost:8000")
|
||||
|
||||
# Wait for some time to catch initialization errors
|
||||
time.sleep(5)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Script error: {e}")
|
||||
finally:
|
||||
browser.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
||||
Reference in new issue
Block a user