commit 9d236d44adc1f1cc97b63d8893598a40c07149e0 Author: Grok Date: Sun Aug 10 12:04:03 2025 +0000 Add example headless browsing script diff --git a/headless_browser_example.py b/headless_browser_example.py new file mode 100644 index 0000000..e13fcfe --- /dev/null +++ b/headless_browser_example.py @@ -0,0 +1,26 @@ +"""Example Python script for headless browsing using Playwright on Linux. + +This script launches a headless Chromium browser, navigates to a webpage, +prints the page title, and closes the browser. + +Requirements: +- Python 3.8+ +- Playwright library: pip install playwright +- Install browsers: playwright install + +Optimized for low resource usage. +""" + +from playwright.sync_api import sync_playwright + +def main(): + with sync_playwright() as p: + # Launch headless browser with minimal options for efficiency + browser = p.chromium.launch(headless=True, args=['--no-sandbox', '--disable-gpu']) + page = browser.new_page() + page.goto('https://example.com') + print(f"Page title: {page.title()}") + browser.close() + +if __name__ == '__main__': + main()