diff --git a/docs/quickstart.mdx b/docs/quickstart.mdx index c93e63a45..4f2ac0e9f 100644 --- a/docs/quickstart.mdx +++ b/docs/quickstart.mdx @@ -150,3 +150,26 @@ if __name__ == "__main__": Custom browsers can be configured in one line. Check out browsers for more. + +## Advanced: CodeAgent for Local Code Execution + +For tasks that require combining browser automation with local code execution (like processing data, saving files, or running computations), use the `CodeAgent`: + +```python +import asyncio +from browser_use.code_use import CodeAgent + +async def main(): + task = "Go to Hacker News, extract the top 10 posts, and save them to posts.json" + agent = CodeAgent(task=task, max_steps=25) + + try: + session = await agent.run() + finally: + await agent.close() + +if __name__ == "__main__": + asyncio.run(main()) +``` + +The `CodeAgent` executes Python code locally (like Claude Code) while having full access to browser automation capabilities. Learn more in the CodeAgent documentation. diff --git a/examples/simple.py b/examples/simple.py index 5bd166b27..8446e9575 100644 --- a/examples/simple.py +++ b/examples/simple.py @@ -11,7 +11,8 @@ from browser_use import Agent, ChatBrowserUse load_dotenv() agent = Agent( - task='Find the number of stars of the following repos: browser-use, playwright, stagehand, react, nextjs', + task='https://wcpdev.wd101.myworkday.com/wday/authgwy/nayyabow_wcpdev2/login.html?returnTo=%2fnayyabow_wcpdev2%2fd%2fhome.html go here click and then fill with example data, use only send keys ', + # task='go to duckduckgo.com search for browser-use but use only send keys validate the results, go to first link', llm=ChatBrowserUse(), ) agent.run_sync()