# examples/extract_data.py
"""Data extraction example."""

import asyncio
from surfai import Browser


async def main():
    """Example: Extract structured data from a page."""
    async with Browser() as browser:
        await browser.goto("https://news.ycombinator.com")
        
        # Extract using natural language
        print("Extracting top stories...")
        stories = await browser.extract("Get the titles of the top 5 stories")
        print(f"Stories: {stories}")
        
        # Take screenshot
        await browser.screenshot("hackernews.png")


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