Skip to main content

Playwright-based browser automation service with HTTP API and Docker support

Project description

:performing_arts: browsy

browsy is a lightweight queue system for browser automation tasks. It lets you easily schedule and run operations like screenshots, PDF generation, and web scraping through a simple HTTP API - all without external dependencies.

Getting Started

The simplest way to spin browsy up is with Docker Compose. Check out the documentation for all the details, but below is the quick and easy way to jump right in.

Here's what you need to do:

  • Install browsy
  • Copy docker-compose.yml
  • Define jobs
  • Run docker compose
  • That's it! Just send requests to queue jobs and grab their results when they're done

Quick Start

Install browsy

pip install browsy

Copy docker compose

git clone ...

Define a job

jobs/screenshot.py:

from browsy import BaseJob, Page

class ScreenshotJob(BaseJob):
    NAME = "screenshot"

    url: str | None = None
    html: str | None = None
    full_page: bool = False

    async def execute(self, page: Page) -> bytes:
        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:
        # Ensure only one target is given, never both
        if bool(self.url) == bool(self.html):
            return False
        
        return True

In this example url, html and full_page are fields from Pydantic's BaseModel. They are used for new jobs validation.

Run browsy

docker compose up --build

That's it!

Using browsy

Trigger a job execution:

from browsy import BrowsyClient

client = BrowsyClient("http://127.0.0.1")
job_id = client.add_job("screenshot", {"url": "https://broton.dev", full_page=True})
screenshot = client.get_result(job_id=job_id).content

Architecture

flow

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.1.tar.gz (207.7 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.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: browsy-0.0.1.tar.gz
  • Upload date:
  • Size: 207.7 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.1.tar.gz
Algorithm Hash digest
SHA256 5ddd0500ab4bf5d61544fddcfdac199d70fe26cea2f955f736e38f0c7180eae7
MD5 e61c47a8bd7f730692a8732fa00a75ff
BLAKE2b-256 ce88f049ecc69bd8bf3978f18cbf716bde3e8bbdd97a4cafe8bf226ceb767744

See more details on using hashes here.

Provenance

The following attestation bundles were made for browsy-0.0.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: browsy-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.7 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aab0fdd0799ebb2c82175e801273b28e866b545cd36a45dc4a077d05beb5eafc
MD5 cf400bcb008dba3c7a0401fc006545e5
BLAKE2b-256 d2d1663bd5d739ce8690fd4f5e16263d7c112f93eb68a789ab4e56fed9912029

See more details on using hashes here.

Provenance

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