22 lines
632 B
Python
22 lines
632 B
Python
#!/usr/bin/env python3
|
|
"""Test if browser can access network"""
|
|
|
|
from playwright.sync_api import sync_playwright
|
|
|
|
with sync_playwright() as p:
|
|
browser = p.chromium.launch(headless=True)
|
|
page = browser.new_page()
|
|
|
|
print("Testing network access...")
|
|
print("1. Testing example.com...")
|
|
page.goto("https://example.com", timeout=30000)
|
|
print(f" Title: {page.title()}")
|
|
|
|
print("2. Testing zhihu.com...")
|
|
page.goto("https://www.zhihu.com", timeout=30000)
|
|
print(f" Title: {page.title()}")
|
|
print(f" URL: {page.url}")
|
|
|
|
browser.close()
|
|
print("✅ Browser network test passed")
|