Skip to content

Instantly share code, notes, and snippets.

@imshaiknasir
Created February 5, 2025 11:32
Show Gist options
  • Save imshaiknasir/d6b618406a2eba21a220fb5241d7a7b3 to your computer and use it in GitHub Desktop.
Save imshaiknasir/d6b618406a2eba21a220fb5241d7a7b3 to your computer and use it in GitHub Desktop.
browserUse_Amazon_Demo
from langchain_google_genai import ChatGoogleGenerativeAI
from browser_use import Agent
from dotenv import load_dotenv
from pydantic import SecretStr
import asyncio
import os
load_dotenv()
async def main():
llm = ChatGoogleGenerativeAI(
model="gemini-2.0-flash-exp",
api_key=SecretStr(os.getenv("GEMINI_API_KEY", "")),
)
agent = Agent(
task="""
1. Navigate to amazon.in
2. In the search bar, enter 'laptop' and press enter
3. Wait for the search results page to load completely
4. On the left sidebar, locate the 'Price' filter
5. Set the minimum price to ₹500 and maximum price to ₹4000 (if you are unable to do it, then manipulate the price in URL itself, example:`?k=laptop&low-price=370&high-price=4500`)
6. Wait for the filtered results to load
7. For each laptop in the results:
- Extract the product name
- Extract the current price
- Extract the original price (if available)
8. Return the results in a structured format with product names and prices
""",
llm=llm,
)
result = await agent.run()
print(result)
asyncio.run(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment