pybrowser
Python browser for PyDroid. No Chromium, Playwright, or PC host is required on the phone.
Fixes Python webbrowser gaps: click/fill/scrape, CSS + XPath, HTTP status, cookies, tab reuse/close, headless (no GUI). Browser.launch() fetches pages with httpx and parses HTML. Optional remote Chromium on PC.
Install (PyDroid)
pip install -U pybroswer
Import name:
from pybrowser import Browser
from pybroswer import Browser still works.
Check:
import pybrowser
print(pybrowser.__version__, pybrowser.__file__)
PyDroid usage
from pybrowser 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 pybrowser serve --port 5173
From PyDroid:
from pybrowser 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
evaluateonly supports simpledocument.title/querySelectorexpressions- 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 pybrowser 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 |
page.xpath("//a") / page.scrape("a", attr="href") |
XPath and scrape |
page.status() / page.ok() / page.response_headers() |
HTTP response |
browser.open(url) / browser.open(url, new=0) |
reuse tab, no spam |
browser.new_tab(url) / browser.close_all() |
tab control |
page.evaluate("document.title") |
read page |
page.html() / page.inspect(selector) |
DOM |
Metadata
Release files for pybroswer 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pybroswer-0.5.1.tar.gz | 34.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pybroswer-0.5.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 71.0 kB
Release files / pybroswer-0.5.1.tar.gz
| Download URL | pybroswer-0.5.1.tar.gz |
|---|---|
| Size | 34.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
af07b684508cd781ebcc1e63dbede9379c766c01f06f43110fef45f523148959
|
|
BLAKE2b-256 checksum How to use checksums |
2d64955716ed27f67ff5ddebcd6e4727a876cac5997d81393a60ab9b496bb568
|
| 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.5.1-py3-none-any.whl
| Download URL | pybroswer-0.5.1-py3-none-any.whl |
|---|---|
| Size | 36.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
79130ecdd386679ebe4ddf582d78ff4d0536873c31b7a4f9026596abfb72563c
|
|
BLAKE2b-256 checksum How to use checksums |
297c0011f6995b17ea3e374620fa3099bd8542d6caebd13c16f8499000bc7a41
|
| 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.5.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.