# examples/basic_usage.py
"""Basic usage example of SurfAI."""

import asyncio
from surfai import Browser


async def main():
    """Example: Navigate and extract data."""
    async with Browser() as browser:
        # Navigate to a page
        await browser.goto("https://github.com/openclaw/openclaw")
        
        # Get page info
        title = await browser.get_title()
        url = await browser.get_url()
        print(f"Page: {title}")
        print(f"URL: {url}")
        
        # Extract data using CSS selector
        try:
            stars = await browser.extract("[href='/openclaw/openclaw/stargazers']")
            print(f"Stars: {stars}")
        except Exception as e:
            print(f"Could not extract stars: {e}")
        
        # Take a screenshot
        await browser.screenshot("github_screenshot.png")
        print("Screenshot saved to github_screenshot.png")


if __name__ == "__main__":
    asyncio.run(main())
