Skip to main content

pybroswer

Python browser for PyDroid. No Chromium, Playwright, or PC host is required on the phone.

More than Python's webbrowser module: cookies, click-by-text, form fill, downloads, history, headers, and DOM query. Browser.launch() fetches pages with httpx and parses HTML. The same API also works with remote Chromium.

Install (PyDroid)

pip install httpx
pip install https://github.com/prateeknishad305/Pybrowser/archive/refs/heads/master.zip

If that fails, install httpx first, then:

pip install git+https://github.com/prateeknishad305/Pybrowser.git

Import name:

from pybroswer import Browser

from pybrowser import Browser also works.

Check:

import pybroswer
print(pybroswer.__version__, pybroswer.__file__)

PyDroid usage

from pybroswer import Browser

with Browser.launch() as browser:
    shot = browser.browse("https://example.com")
    print(shot.title, shot.url, shot.text)

    with browser.create_session(device="mobile") as page:
        page.goto("https://example.com")
        print(page.title(), page.url())
        print(page.text()[:200])
        print(page.links())
        print(page.cookies())

        # Click first real link, or pass CSS / visible text:
        # page.click()
        # page.click("a#login")
        # page.click(text="More information")
        # page.click("text=More information")
        # page.fill({"q": "hello"})
        # page.press("Enter", selector="input[name=q]")

Browser() with no URL also starts the local HTTP engine.

Optional: PC Chromium

If you want real Chromium on a PC:

pip install "pybroswer[chromium]"
playwright install chromium
python -m pybroswer serve --port 5173

From PyDroid:

from pybroswer import Browser
with Browser.connect("http://192.168.1.10:5173") as browser:
    ...

In-process on PC: Browser.launch(engine="chromium").

Limits (phone HTTP engine)

  • JS-heavy SPAs are not rendered (you get the HTML the server sent)
  • Screenshot is a 1x1 placeholder PNG
  • evaluate only supports simple document.title / querySelector expressions
  • Iframe contents are not fetched separately
  • Click coordinates (x, y) require Chromium

Forms, links, cookies, downloads, type/press/select, headers, and redirects work.

Beyond webbrowser.open(url):

from pybroswer import Browser

browser = Browser.launch()
browser.open("https://example.com")   # webbrowser-compatible
with browser.create_session() as page:
    page.goto("https://httpbin.org/forms/post")
    page.fill({"custname": "Ada", "custtel": "123"})
    page.click("text=Submit")
    print(page.cookies())
    file = page.download("https://example.com/favicon.ico")
    print(file["filename"], file["bytes"])

API

Method
Browser.launch() local HTTP engine (PyDroid default)
Browser.launch(engine="chromium") Playwright Chromium (PC)
Browser.connect(url) remote REST
browser.browse(url) one-shot open
page.goto / click / type / press / select session actions
page.click(text="Login") / page.fill({...}) text click, form fill
page.cookies() / page.download(url) cookies and files
page.links() / page.query(selector) page query
browser.open(url) webbrowser-compatible
page.evaluate("document.title") read page
page.html() / page.inspect(selector) DOM

Metadata

Release files for pybroswer 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pybroswer 0.4.1
File Size Uploaded Provenance
pybroswer-0.4.1.tar.gz 32.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pybroswer 0.4.1
File Interpreter ABI Platform
pybroswer-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 64.8 kB

Release files / pybroswer-0.4.1.tar.gz

Download URL pybroswer-0.4.1.tar.gz
Size 32.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8590da51e7292908f017202b7d39a7f5894b78b3e1cee57a640cde701a64f926
BLAKE2b-256 checksum
How to use checksums
7cb12370003be73419099e8bcc9d6c42a2fc0c2bbc73351873efd2b1116bc7c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.2

Release files / pybroswer-0.4.1-py3-none-any.whl

Download URL pybroswer-0.4.1-py3-none-any.whl
Size 32.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a3734ef1f8123abf2883040a1ba13801299af7416501fb268c5e0a5bcb12e8b
BLAKE2b-256 checksum
How to use checksums
ddc0b7aa22eb6cbfcd0143517ddce8cd6f155adc4bb3dec71cce6e64e057ee02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.2

Security for pybroswer 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page