Skip to content

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

Only option for markdown or text depending if links are needed

magmueller18a42db882a3
diff --git a/browser_use/controller/service.py b/browser_use/controller/service.py
index 350e2b4d0..08f4f5eac 100644
--- a/browser_use/controller/service.py
+++ b/browser_use/controller/service.py
@@ -153,18 +153,18 @@ class Controller:
# Content Actions
@self.registry.action(
- 'Extract page content to get the text or markdown ',
+ 'Extract page content to get the pure text or markdown with links if include_links is set to true',
param_model=ExtractPageContentAction,
requires_browser=True,
)
async def extract_content(params: ExtractPageContentAction, browser: BrowserContext):
page = await browser.get_current_page()
-
+ output_format = 'markdown' if params.include_links else 'text'
content = MainContentExtractor.extract( # type: ignore
html=await page.content(),
- output_format=params.value,
+ output_format=output_format,
)
- msg = f'📄 Extracted page content\n: {content}\n'
+ msg = f'📄 Extracted page as {output_format}\n: {content}\n'
logger.info(msg)
return ActionResult(extracted_content=msg)
diff --git a/browser_use/controller/views.py b/browser_use/controller/views.py
index b236814c2..f1f92b7fc 100644
--- a/browser_use/controller/views.py
+++ b/browser_use/controller/views.py
@@ -36,7 +36,7 @@ class OpenTabAction(BaseModel):
class ExtractPageContentAction(BaseModel):
- value: Literal['text', 'markdown', 'html'] = 'text'
+ include_links: bool = False
class ScrollAction(BaseModel):