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
add anti detection via rebrowser
neo7739d1f6fae6189
diff --git a/browser_use/browser/browser.py b/browser_use/browser/browser.pyindex 5d887796e..f769248e3 100644--- a/browser_use/browser/browser.py+++ b/browser_use/browser/browser.py@@ -6,9 +6,9 @@ import asyncioimport loggingfrom dataclasses import dataclass, field-from playwright._impl._api_structures import ProxySettings-from playwright.async_api import Browser as PlaywrightBrowser-from playwright.async_api import (+from rebrowser_playwright._impl._api_structures import ProxySettings+from rebrowser_playwright.async_api import Browser as PlaywrightBrowser+from rebrowser_playwright.async_api import (Playwright,async_playwright,)@@ -179,24 +179,6 @@ class Browser:"""Sets up and returns a Playwright Browser instance with anti-detection measures."""browser = await playwright.chromium.launch(headless=self.config.headless,- args=[- '--no-sandbox',- '--disable-blink-features=AutomationControlled',- '--disable-infobars',- '--disable-background-timer-throttling',- '--disable-popup-blocking',- '--disable-backgrounding-occluded-windows',- '--disable-renderer-backgrounding',- '--disable-window-activation',- '--disable-focus-on-load',- '--no-first-run',- '--no-default-browser-check',- '--no-startup-window',- '--window-position=0,0',- # '--window-size=1280,1000',- ]- + self.disable_security_args- + self.config.extra_chromium_args,proxy=self.config.proxy,)# convert to Browserdiff --git a/browser_use/browser/context.py b/browser_use/browser/context.pyindex 06d3b1e51..b38ac5439 100644--- a/browser_use/browser/context.py+++ b/browser_use/browser/context.py@@ -13,11 +13,11 @@ import uuidfrom dataclasses import dataclass, fieldfrom typing import TYPE_CHECKING, Optional, TypedDict-from playwright.async_api import Browser as PlaywrightBrowser-from playwright.async_api import (+from rebrowser_playwright.async_api import Browser as PlaywrightBrowser+from rebrowser_playwright.async_api import (BrowserContext as PlaywrightBrowserContext,)-from playwright.async_api import (+from rebrowser_playwright.async_api import (ElementHandle,FrameLocator,Page,@@ -117,9 +117,7 @@ class BrowserContextConfig:save_downloads_path: str | None = Nonetrace_path: str | None = Nonelocale: str | None = None- user_agent: str = (- 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36'- )+ user_agent: str | None = Nonehighlight_elements: bool = Trueviewport_expansion: int = 500@@ -246,7 +244,7 @@ class BrowserContext:context = await browser.new_context(viewport=self.config.browser_window_size,no_viewport=False,- user_agent=self.config.user_agent,+ **({"user_agent": self.config.user_agent} if self.config.user_agent is not None else {}),java_script_enabled=True,bypass_csp=self.config.disable_security,ignore_https_errors=self.config.disable_security,@@ -268,23 +266,6 @@ class BrowserContext:# Expose anti-detection scriptsawait context.add_init_script("""- // Webdriver property- Object.defineProperty(navigator, 'webdriver', {- get: () => undefined- });-- // Languages- Object.defineProperty(navigator, 'languages', {- get: () => ['en-US']- });-- // Plugins- Object.defineProperty(navigator, 'plugins', {- get: () => [1, 2, 3, 4, 5]- });-- // Chrome runtime- window.chrome = { runtime: {} };// Permissionsconst originalQuery = window.navigator.permissions.query;diff --git a/browser_use/dom/service.py b/browser_use/dom/service.pyindex e60c16923..a503a73f5 100644--- a/browser_use/dom/service.py+++ b/browser_use/dom/service.py@@ -2,7 +2,7 @@ import loggingfrom importlib import resourcesfrom typing import Optional-from playwright.async_api import Page+from rebrowser_playwright.async_api import Pagefrom browser_use.dom.history_tree_processor.view import Coordinatesfrom browser_use.dom.views import (diff --git a/docs/customize/agent-settings.mdx b/docs/customize/agent-settings.mdxindex efa434225..5a43bb4b9 100644--- a/docs/customize/agent-settings.mdx+++ b/docs/customize/agent-settings.mdx@@ -91,7 +91,7 @@ await browser.close()```pythonfrom browser_use import Agent, Browser-from playwright.async_api import BrowserContext+from rebrowser_playwright.async_api import BrowserContext# Use specific browser context (preferred method)async with await browser.new_context() as context:diff --git a/examples/notebook/agent_browsing.ipynb b/examples/notebook/agent_browsing.ipynbindex 2b5ae837d..a960b5a4e 100644--- a/examples/notebook/agent_browsing.ipynb+++ b/examples/notebook/agent_browsing.ipynb@@ -684,7 +684,7 @@"cell_type": "code","source": ["from browser_use import Agent, Browser\n",- "from playwright.async_api import BrowserContext\n",+ "from rebrowser_playwright.async_api import BrowserContext\n","from browser_use import BrowserConfig\n","from langchain_openai import ChatOpenAI\n","# from browser_use import Agent\n",diff --git a/pyproject.toml b/pyproject.tomlindex d48241f46..6c564347a 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -27,7 +27,7 @@ dependencies = ["python-dotenv>=1.0.1","requests>=2.32.3","posthog>=3.7.0",- "playwright>=1.49.0",+ "rebrowser-playwright>=1.49.0","setuptools>=75.8.0","lmnr[langchain]>=0.4.53"]diff --git a/tests/test_attach_chrome.py b/tests/test_attach_chrome.pyindex c527da4c1..dd5b003f0 100644--- a/tests/test_attach_chrome.py+++ b/tests/test_attach_chrome.py@@ -1,7 +1,7 @@import argparseimport asyncio-from playwright.async_api import async_playwright+from rebrowser_playwright.async_api import async_playwrightasync def test_full_screen(start_fullscreen: bool, maximize: bool):diff --git a/tests/test_full_screen.py b/tests/test_full_screen.pyindex 3926761de..d31979f29 100644--- a/tests/test_full_screen.py+++ b/tests/test_full_screen.py@@ -1,7 +1,7 @@import argparseimport asyncio-from playwright.async_api import async_playwright+from rebrowser_playwright.async_api import async_playwrightasync def test_full_screen(start_fullscreen: bool, maximize: bool):