Skip to main content

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

  1. Install browsy:
pip install browsy
  1. 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
  1. Run browsy:
docker compose up --build
  1. 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

flow

  1. You define jobs using Playwright's API
  2. Send job requests through HTTP
  3. Workers execute jobs in Docker containers
  4. 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

browsy-0.0.2.tar.gz (207.9 kB view details)

Uploaded Source

Built Distribution

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

browsy-0.0.2-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file browsy-0.0.2.tar.gz.

File metadata

  • Download URL: browsy-0.0.2.tar.gz
  • Upload date:
  • Size: 207.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for browsy-0.0.2.tar.gz
Algorithm Hash digest
SHA256 9a320102500f5f16d23081ed5556c28aa2462f029ac07214f7df72be2929978e
MD5 54b2042fe20d41f6a7157f3e45fc33e2
BLAKE2b-256 028c4919724ed60d5cfcc44eff480164c3908757dac74425fec9fde68a383d8a

See more details on using hashes here.

Provenance

The following attestation bundles were made for browsy-0.0.2.tar.gz:

Publisher: publish-pypi-docker.yml on mbroton/browsy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file browsy-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: browsy-0.0.2-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

Hashes for browsy-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7c9eda3e1d80140632351f9e212b90b45628d2cbadce55cd292d2eaa041c972e
MD5 e658a10aca710bfec5b021a0557e36fa
BLAKE2b-256 2af377dc2ab8278c7d3d688f1731f8c12191236490560bea64cfc6d1205b58d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for browsy-0.0.2-py3-none-any.whl:

Publisher: publish-pypi-docker.yml on mbroton/browsy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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