Skip to content

Instantly share code, notes, and snippets.

@rajivmehtaflex
Created March 10, 2025 11:30
Show Gist options
  • Save rajivmehtaflex/20de69767c06160fd2e480d00347b22c to your computer and use it in GitHub Desktop.
Save rajivmehtaflex/20de69767c06160fd2e480d00347b22c to your computer and use it in GitHub Desktop.
browser_use Related Notes.
#uv add browser-use
#playwright install-dep
#playwright install-deps
#playwright install
import asyncio
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from browser_use.browser.browser import Browser, BrowserConfig
from browser_use import Agent
import os
os.environ['OPENAI_API_KEY'] = '<KEY>'
# Initialize the model
llm = ChatOpenAI(
model='gpt-4o-mini',
temperature=0.0,
)
config = BrowserConfig(
headless=True,
disable_security=True,
)
browser = Browser(config=config)
task = '''
goto https://openrouter.ai/openai
step-1:scroll to 300 px down
step-2:get the model name
step-1:scroll to 300 px down
step-2:get the model name
you need to perform step-1 and step-2 until you get the string 'OpenAI: o1-mini (2024-09-12)'
make sure get the model name on each step
'''
agent = Agent(task=task, llm=llm, browser=browser)
async def main():
history = await agent.run(max_steps=100)
return history
if __name__ == '__main__':
asyncio.run(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment