Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
Merge pull request #981 from Nimbleway/make-extraction-context-smaller
Nick Sweeting7eaf1e2737ad
diff --cc browser_use/controller/service.pyindex 7c3f78b45,89ab38d2e..6af833ae0--- a/browser_use/controller/service.py+++ b/browser_use/controller/service.py@@@ -266,14 -183,12 +266,18 @@@ class Controller(Generic[Context])page = await browser.get_current_page()import markdownify- content = markdownify.markdownify(await page.content())+ strip = []+ if should_strip_link_urls:+ strip = ['a', 'img']++ content = markdownify.markdownify(await page.content(), strip=strip)+ # manually append iframe text into the content so it's readable by the LLM (includes cross-origin iframes)+ for iframe in page.frames:+ if iframe.url != page.url and not iframe.url.startswith('data:'):+ content += f'\n\nIFRAME {iframe.url}:\n'+ content += markdownify.markdownify(await iframe.content())+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)try: