Playwright-based browser automation service with HTTP API and Docker support
Project description
browsy
What is browsy?
browsy is a service that lets you run browser automation tasks without managing browser instances yourself. It provides:
- Simple Job Definition: Write Playwright-powered automation tasks in Python
- HTTP API: Queue jobs and retrieve results through HTTP endpoints
- Docker Ready: Run everything in containers without worrying about browser dependencies
- Queue System: Jobs are processed in order, with automatic retries and status tracking
- Extensible: Create any browser automation task - from screenshots and PDFs to complex scraping operations
Think of it as a way to turn your Playwright scripts into HTTP services that can be called from anywhere.
Quick Start
- Install browsy:
pip install browsy
- Define a job (e.g.,
jobs/screenshot.py):
from browsy import BaseJob, Page
# Define a job by inheriting from BaseJob (which works like Pydantic's BaseModel)
# and giving it a unique name
class ScreenshotJob(BaseJob):
# This name will be used to identify the job type when making API calls
NAME = "screenshot"
# Define job parameters
# All of these will be automatically parsed from the JSON request
url: str | None = None # URL to take screenshot of
html: str | None = None # Or raw HTML to render
full_page: bool = False # Whether to capture the full scrollable page
async def execute(self, page: Page) -> bytes:
# This is where the actual browser automation happens
# `page` is a Playwright `Page` object with all its methods available
if self.url:
await page.goto(self.url)
elif self.html:
await page.set_content(self.html)
return await page.screenshot(full_page=self.full_page)
async def validate_logic(self) -> bool:
# Optional validation method that runs when submitting a new job
# Here we check that exactly one of url/html is provided
if bool(self.url) == bool(self.html):
return False
return True
- Run browsy:
docker compose up --build
- Use it:
from browsy import BrowsyClient
client = BrowsyClient("http://127.0.0.1")
job_id = client.add_job("screenshot", {
"url": "https://example.com",
"full_page": True
})
screenshot = client.get_result(job_id=job_id).content
How it works
- You define jobs using Playwright's API
- Send job requests through HTTP
- Workers execute jobs in Docker containers
- Get results when ready
Documentation
For detailed setup and usage, check out the documentation.
License
MIT License - see LICENSE for details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file browsy-0.0.3.tar.gz.
File metadata
- Download URL: browsy-0.0.3.tar.gz
- Upload date:
- Size: 210.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
488d0166bf244db36ee2f609f26f95e114c371d71b0a20836b8a2df2cb89f0c7
|
|
| MD5 |
7561546f497e336d5b8061ac15570b1b
|
|
| BLAKE2b-256 |
cde28f1e5d27c37342057d32c33bca70d305b52c651e76ebc3b617f6bf3bf31c
|
Provenance
The following attestation bundles were made for browsy-0.0.3.tar.gz:
Publisher:
publish-pypi-docker.yml on mbroton/browsy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
browsy-0.0.3.tar.gz -
Subject digest:
488d0166bf244db36ee2f609f26f95e114c371d71b0a20836b8a2df2cb89f0c7 - Sigstore transparency entry: 158125214
- Sigstore integration time:
-
Permalink:
mbroton/browsy@cbec29154167ee8a9c9db245b5d74c765f85a4f0 -
Branch / Tag:
refs/tags/v0.0.3 - Owner: https://github.com/mbroton
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi-docker.yml@cbec29154167ee8a9c9db245b5d74c765f85a4f0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file browsy-0.0.3-py3-none-any.whl.
File metadata
- Download URL: browsy-0.0.3-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2695610fba1c4db6bb28f956c4bdca810de1fb6352c035cc9e111c9553a2221
|
|
| MD5 |
88f303b8cf561b7357bd4977726161cf
|
|
| BLAKE2b-256 |
a8ecec26ef101b88350fe03308b026b09b48c1336520930fdb84f755b3eed261
|
Provenance
The following attestation bundles were made for browsy-0.0.3-py3-none-any.whl:
Publisher:
publish-pypi-docker.yml on mbroton/browsy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
browsy-0.0.3-py3-none-any.whl -
Subject digest:
b2695610fba1c4db6bb28f956c4bdca810de1fb6352c035cc9e111c9553a2221 - Sigstore transparency entry: 158125215
- Sigstore integration time:
-
Permalink:
mbroton/browsy@cbec29154167ee8a9c9db245b5d74c765f85a4f0 -
Branch / Tag:
refs/tags/v0.0.3 - Owner: https://github.com/mbroton
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi-docker.yml@cbec29154167ee8a9c9db245b5d74c765f85a4f0 -
Trigger Event:
release
-
Statement type: