Skip to content

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

Document document text extraction helper

Magnus Müller3fb8a0ce8eb5
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/RUST_AGENT_INTEGRATION_FEATURES.md
index 2aa21b9f0..3e5e97de7 100644
--- a/RUST_AGENT_INTEGRATION_FEATURES.md
+++ b/RUST_AGENT_INTEGRATION_FEATURES.md
@@ -221,6 +221,11 @@ Terminal core branch: `magnus/browser-use-rust-integration` at latest pulled mai
- The helper extracts bounded records from JSON-LD, Next.js/Nuxt hydration payloads, JSON script tags, and product/document meta tags, normalizing names, URLs, images, prices, dates, brands, descriptions, source metadata, and raw scalar fields.
- Proof: `browser_script_embedded_data_snapshot_extracts_hydration_records`.
+43. Browser-script document text extraction helper
+ - Terminal browser scripts now expose `read_document_text(source, headers=None, timeout=30.0, max_chars=120000, binary=None)`.
+ - The helper reads local paths or HTTP(S) document URLs and extracts bounded text from text/HTML, DOCX, and PDF sources using available Python PDF libraries, `pdftotext`, or a PDF byte-string fallback.
+ - Proof: `browser_script_read_document_text_extracts_common_document_formats`.
+
## Current Verification
- `python3 -m py_compile browser_use/rust/service.py browser_use/rust/__init__.py browser_use/__init__.py tests/ci/test_rust_agent.py examples/rust_agent/basic.py examples/rust_agent/real_v8_smoke.py`
@@ -241,6 +246,7 @@ Terminal core branch: `magnus/browser-use-rust-integration` at latest pulled mai
- `CARGO_INCREMENTAL=0 cargo test -q -p browser-use-browser browser_script_helpers_enforce_domain_constraints_env -- --nocapture`
- `CARGO_INCREMENTAL=0 cargo test -q -p browser-use-browser browser_script_navigation_snapshot_surfaces_menu_and_route_links -- --nocapture`
- `CARGO_INCREMENTAL=0 cargo test -q -p browser-use-browser browser_script_embedded_data_snapshot_extracts_hydration_records -- --nocapture`
+- `CARGO_INCREMENTAL=0 cargo test -q -p browser-use-browser browser_script_read_document_text_extracts_common_document_formats -- --nocapture`
- Managed-headless end-to-end:
- `BROWSER_USE_TERMINAL_BINARY=/home/exedev/Developer/terminal/target/debug/browser-use-terminal BROWSER_USE_RUST_BROWSER_MODE=managed-headless BU_TASK='Open https://example.com and report the page title only.' BU_MAX_STEPS=12 timeout 300 uv run python examples/rust_agent/basic.py`
- Output: `Example Domain`