Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Extract hn content

magmueller3ee6c731a17d
diff --git a/README.md b/README.md
index 8fc1fc0a7..9754a7116 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ from src import Agent
from langchain_openai import ChatOpenAI
agent = Agent(
- task='Go to hackernews on show hn and give me the 10 top post titels and how many points each has. Calculate for each the ratio of points per hour. Then ask user me for further instructions.',
+ task='Go to hackernews on show hn and give me top 10 post titels, their points and hours. Calculate for each the ratio of points per hour. All in a json format title, points, hours, ratio. Then ask me for further instructions.',
llm=ChatOpenAI(model='gpt-4o'),
)
@@ -26,15 +26,9 @@ await agent.run()
```
## Demo
-<div>
- <a href="https://www.loom.com/share/c89aaa33b4c340ea92e11298b69f2cc7">
- <p>Re: - 6 November 2024 - Watch Video</p>
- </a>
- <a href="https://www.loom.com/share/c89aaa33b4c340ea92e11298b69f2cc7">
- <img style="max-width:300px;" src="https://cdn.loom.com/sessions/thumbnails/c89aaa33b4c340ea92e11298b69f2cc7-a266705b9047aa7b-full-play.gif">
- </a>
- <p><i>Prompt: Go to hackernews on show hn and give me the 10 top post titels and how many points each has. Calculate for each the ratio of points per hour. (1x speed)</i></p>
- </div>
+<div style="position: relative; padding-bottom: 64.92178098676294%; height: 0;"><iframe src="https://www.loom.com/embed/2af938b9f8024647950a9e18b3946054?sid=d95ece0b-6a17-477e-a223-b558645e6e89" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></iframe>
+</div>
+
<div>
<a href="https://www.loom.com/share/2af938b9f8024647950a9e18b3946054">
<p>gregpr07/browser-use at Example-improvement - 6 November 2024 - Watch Video</p>
@@ -137,7 +131,7 @@ python examples/try.py "Search the top 3 AI companies 2024 and find out in 3 new
You need to add `OPENAI_API_KEY` to your environment variables. Example usage:
```bash
-python examples/try.py "Go to hackernews on show hn and give me the 10 top post titels and how many points each has. Calculate for each the ratio of points per hour. Then ask me for further clarification." --provider openai
+python examples/try.py "Go to hackernews on show hn and give me top 10 post titels, their points and hours. Calculate for each the ratio of points per hour. Then ask me for further instructions." --provider anthropic
```
## 🤖 Supported Models
diff --git a/src/browser/service.py b/src/browser/service.py
index 5fd542215..c0c029fb4 100644
--- a/src/browser/service.py
+++ b/src/browser/service.py
@@ -3,13 +3,12 @@ Selenium browser on steroids.
"""
import base64
+import logging
import os
import tempfile
import time
from typing import Literal
-import logging
-
from main_content_extractor import MainContentExtractor
from Screenshot import Screenshot
from selenium import webdriver
@@ -262,6 +261,7 @@ class BrowserService:
# Then send keys
element.send_keys(text)
+ logger.info(f'Input text into element with xpath: {xpath}')
self.wait_for_page_load()
@@ -342,6 +342,7 @@ class BrowserService:
xpath = state.selector_map[index]
self._click_element_by_xpath(xpath)
+ logger.info(f'Clicked on index {index}: with xpath {xpath}')
# Check if new tab was opened
current_handles = len(driver.window_handles)