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.3.tar.gz (210.6 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.3-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

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

Hashes for browsy-0.0.3.tar.gz
Algorithm Hash digest
SHA256 488d0166bf244db36ee2f609f26f95e114c371d71b0a20836b8a2df2cb89f0c7
MD5 7561546f497e336d5b8061ac15570b1b
BLAKE2b-256 cde28f1e5d27c37342057d32c33bca70d305b52c651e76ebc3b617f6bf3bf31c

See more details on using hashes here.

Provenance

The following attestation bundles were made for browsy-0.0.3.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.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

Hashes for browsy-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b2695610fba1c4db6bb28f956c4bdca810de1fb6352c035cc9e111c9553a2221
MD5 88f303b8cf561b7357bd4977726161cf
BLAKE2b-256 a8ecec26ef101b88350fe03308b026b09b48c1336520930fdb84f755b3eed261

See more details on using hashes here.

Provenance

The following attestation bundles were made for browsy-0.0.3-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