Skip to main content

Patching Browser Use to make it work with more websites and URLs ...

Project description

Enable AI to control your browser 🤖

A patched, drop-in replacement for browser-use, capable of defeating Cloudflare's verification.

- NOTE: 
- It seems that after getting rid of Playwright and having done an amazing piece of work developing 
- their own event bus and SafeType CDP client, this use case is still not being contemplated by
- browser-use, so I had to do it myself... 😎

- Pre 0.6.1 versions of this project used to depend on a tweaked version of patchright 
- (https://github.com/imamousenotacat/re-patchright) but not anymore.

This little project was created because I was fed up with getting blocked by Cloudflare's verification and I wanted to do things like this with Browser Use:

python examples\nopecha_cloudflare_no_playwright.py

nopecha_cloudflare.py

I have added OS-level clicks in headful mode to enable the use of ProtonVPN. Once again, credit goes to Vinyzu, as I used a pruned and slightly modified version of his CDP-Patches project for this.

I restored and completed the JavaScript highlighting system that was removed in version 0.7.1 and only partially reincorporated in 0.8.1. I find it extremely useful for my use case.

The one below is a long-awaited browser-use test that was chased for quite a while 😜:

python tests/ci/evaluate_tasks.py --task tests/agent_tasks/captcha_cloudflare.yaml

captcha_cloudflare.yaml

- NOTE:
- This test, captcha_cloudflare.yaml, was removed in version 0.7.6. The browser-use team seems fixated
- on not addressing the Cloudflare challenge 😲. I got it restored here. If you apply the patch
- using the commands in .github/workflows/apply-patches.yaml, you can get it back and successfully
- execute it.

If it looks slow, it is because I'm using a small and free LLM and an old computer worth $100.

Quick start

This is how you can see for yourself how it works:

Clone this repository and using uv install the pip package (Python>=3.11):

git clone https://github.com/imamousenotacat/re-browser-use
cd re-browser-use\
uv venv
.venv\Scripts\activate
uv pip install re-browser-use

Install the browser as described in the browse-use repository.

uvx playwright install chromium --with-deps --no-shell

Create a minimalistic .env file. This is what I use. I'm a poor mouse and I can afford only free things. 🙂

GOOGLE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ANONYMIZED_TELEMETRY=false
SKIP_LLM_API_KEY_VERIFICATION=true
HEADLESS_EVALUATION=false

And finally tell your agent to pass Cloudflare's verification:

python examples\nopecha_cloudflare_no_playwright.py

You will get something very similar to the animated gif above. This is the code of the example file:

import asyncio
from browser_use import BrowserProfile, BrowserSession
from browser_use.agent.service import Agent
from dotenv import load_dotenv
from browser_use.llm import ChatGoogle

load_dotenv()


async def main():
  agent = Agent(
    use_vision=False,
    task=(
      "Go to https://nopecha.com/demo/cloudflare, wait for the verification checkbox to appear, click it once, and wait for 10 seconds."
      "That’s all. If you get redirected, don’t worry."
    ),
    llm=ChatGoogle(model="gemini-2.5-flash-lite"),
    browser_session=BrowserSession(
      browser_profile=BrowserProfile(
        headless=False,
        cross_origin_iframes=True,
        dom_highlight_elements=True
      )
    )
  )
  await agent.run(10)

asyncio.run(main())

If you want to run the same code with "regular" browser-use to compare the results, uninstall re-browser-use and install browser-use instead:

uv pip uninstall re-browser-use
uv pip install --upgrade --force-reinstall browser-use["all"]==0.9.4 # This is the last version I've patched so far

Now run again the script

python examples\nopecha_cloudflare_no_playwright.py

nopecha_cloudflare_unfolded.py KO

With the current versions of browser-use, this still won't work.

Why is this project not a PR?

I don't want to ruffle any feathers, but we, humble but rebellious mice 😜, don't like signing CLAs or working for free for someone who, by their own admission, is here to "dominate". I do this just for fun.

I just wanted to make this work public. If someone finds this useful, they can incorporate it into their own projects.


Citation

If you use Browser Use in your research or project, please cite:

@software{browser_use2024,
  author = {Müller, Magnus and Žunič, Gregor},
  title = {Browser Use: Enable AI to control your browser},
  year = {2024},
  publisher = {GitHub},
  url = {https://github.com/browser-use/browser-use}
}
Made with ❤️ in Zurich and San Francisco

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

re_browser_use-0.9.4.tar.gz (427.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

re_browser_use-0.9.4-py3-none-any.whl (515.2 kB view details)

Uploaded Python 3

File details

Details for the file re_browser_use-0.9.4.tar.gz.

File metadata

  • Download URL: re_browser_use-0.9.4.tar.gz
  • Upload date:
  • Size: 427.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.7

File hashes

Hashes for re_browser_use-0.9.4.tar.gz
Algorithm Hash digest
SHA256 548bf2de00bff8457c78648a57142503ddf7db6d29d4c5ff2c0545a81d174cf5
MD5 47e24a51f5f8d0ef57bcba031c083596
BLAKE2b-256 d1f16f6ba99b861acaa42b20193debe811a57c525bff16b5749b3e055f246ba3

See more details on using hashes here.

File details

Details for the file re_browser_use-0.9.4-py3-none-any.whl.

File metadata

File hashes

Hashes for re_browser_use-0.9.4-py3-none-any.whl
Algorithm Hash digest
SHA256 cfaa82122b22c5d9a78ef93d6732d607e25a2bd0c3ac7164c8b3b20d68751f7b
MD5 39ad40af39e448f5a06372afc115038f
BLAKE2b-256 c1156265a9861114307058823e84d00126f6b9ebb6af800e75b66d5a0b4f162f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page