Spaces:
Sleeping
Sleeping
File size: 983 Bytes
88678e4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import asyncio
from patchright.async_api import async_playwright
import sys
async def main():
print(f"Python: {sys.version}")
print("Attempting to launch Patchright (Chromium)...")
try:
async with async_playwright() as p:
print("Playwright started.")
# Try to verify if we can skip dependency validation if needed
# But usually we just launch
browser = await p.chromium.launch(
headless=True,
args=['--no-sandbox', '--disable-setuid-sandbox'] # often helps in docker/linux
)
print("Browser launched successfully!")
page = await browser.new_page()
await page.goto("https://example.com")
print(f"Page title: {await page.title()}")
await browser.close()
print("Success!")
except Exception as e:
print(f"\nERROR launching browser:\n{e}")
if __name__ == "__main__":
asyncio.run(main())
|