Skip to content

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

Adding the strip to markdownify will keep the text but not add the url to the data. This transformed a text of 367277 characters to 48969. Quick fix to a more deep problem

mkuts12b2fb7c42e765
diff --git a/browser_use/controller/service.py b/browser_use/controller/service.py
index a1ec1f131..fdab9b326 100644
--- a/browser_use/controller/service.py
+++ b/browser_use/controller/service.py
@@ -183,7 +183,7 @@ class Controller(Generic[Context]):
page = await browser.get_current_page()
import markdownify
- content = markdownify.markdownify(await page.content())
+ content = markdownify.markdownify(await page.content(), strip=['a', 'img'])
prompt = 'Your task is to extract the content of the page. You will be given a page and a goal and you should extract all relevant information around this goal from the page. If the goal is vague, summarize the page. Respond in json format. Extraction goal: {goal}, Page: {page}'
template = PromptTemplate(input_variables=['goal', 'page'], template=prompt)