Welcome to Botright!

For full documentation of changes visit BotrightDocumentation. Except of these changes, you can use Botright after the PlaywrightDocs

Installation

Pip

PyPI version

pip install --upgrade pip
pip install botright
playwright install

Usage

Once installed, you can import Botright in a Python script, and launch a firefox browser.

import asyncio
import botright


async def main():
    botright_client = await botright.Botright()
    browser = await botright_client.new_browser()
    page = await browser.new_page()

    await page.goto("http://playwright.dev")
    print(await page.title())

    await botright_client.close()

if __name__ == "__main__":
    asyncio.run(main())

Captchas

Botright is able to solve a wide viarity of Captchas. For Documentation of these functions visit BotrightDocumentation.

Here all Captchas supported as of now

First script

In our first script, we will navigate to whatsmyuseragent.org and take a screenshot in WebKit.

import asyncio
import botright


async def main():
    botright_client = await botright.Botright()
    browser = await botright_client.new_browser()
    page = await browser.new_page()

    page.goto("http://whatsmyuseragent.org/")
    page.screenshot(path="example.png")

    await botright_client.close()

if __name__ == "__main__":
    asyncio.run(main())

By default, Botright runs the browsers in headless mode. To see the browser UI, pass the headless=False flag while launching botright/the browser.

await botright.Botright(headless=False)

Interactive mode (REPL)

You can launch the interactive python REPL:

python -m asyncio

and then launch Botright within it for quick experimentation:

>>> import botright
>>> botright_client = await botright.Botright()
# Pass headless=False to botright.Botright() to see the browser UI
>>> browser = await botright_client.new_browser()
>>> page = await browser.new_page()
>>> await page.goto("http://whatsmyuseragent.org/")
>>> await page.screenshot(path="example.png")
>>> await botright_client.stop()

Pyinstaller

You can use Botright with Pyinstaller to create standalone executables.

# main.py
import asyncio
import botright


async def main():
    botright_client = await botright.Botright()
    browser = await botright_client.new_browser()
    page = await browser.new_page()

    page.goto("http://whatsmyuseragent.org/")
    page.screenshot(path="example.png")

    await botright_client.close()

if __name__ == "__main__":
    asyncio.run(main())

If you want to bundle browsers with the executables:

PLAYWRIGHT_BROWSERS_PATH=0 playwright install firefox
pyinstaller -F main.py
set PLAYWRIGHT_BROWSERS_PATH=0
playwright install firefox
pyinstaller -F main.py
$env:PLAYWRIGHT_BROWSERS_PATH="0"
playwright install firefox
pyinstaller -F main.py

Known issues

Threading

Botright’s API is not thread-safe. If you are using Botright in a multi-threaded environment, you should create a botright instance per thread. See threading issue for more details.