Skip to main content

Lightweight CDP-first browser automation; users are responsible for lawful authorized use.

Project description

playwrong

playwrong is a lightweight browser automation library with a Playwright-like sync/async surface.

If you are an AI coding assistant working on this package, read ai_agent.md first.

It is focused on practical scraping workflows:

  • wrap headful crawling around an already-existing browser instance when available
  • attach to an already-open Chromium/Edge CDP endpoint when possible
  • launch a new debug browser if no endpoint is available
  • provide a small, familiar API (sync_playwright, chromium.launch, connect_over_cdp, new_page, goto, content)
  • optional Firefox backend via Selenium + local undetected_geckodriver wrapper

Primary intent: allow operators to inject an already-running browser into headful crawling so automation can reuse an established session (cookies/auth state) instead of starting from a cold profile every run.

This way you can still get served relevant ads while automating your browser hehe.

Status

Early alpha (0.x). API may evolve.

Install

python -m pip install -e .

Publishing to PyPI

This package includes GitHub Actions pipelines for build/test and publish:

  • projects/playwrong/.github/workflows/ci.yml
  • projects/playwrong/.github/workflows/publish-pypi.yml

Publish flow is configured for trusted publishing with pypa/gh-action-pypi-publish.

Recommended release process:

  1. Push/tag a release (vX.Y.Z) and publish a GitHub Release.
  2. Ensure repository environment pypi exists and is approved for publishing.
  3. Configure PyPI trusted publisher for your GitHub repository/workflow.

Quick start

from playwrong.sync_api import sync_playwright

with sync_playwright(verbose=True) as p:
    browser = p.chromium.connect_over_cdp("http://127.0.0.1:9222")
    page = browser.new_page()
    page.goto("https://example.com", wait_until="load")
    html = page.content()
    browser.close()

Open-browser attach

Start Edge/Chrome with remote debugging first, for example:

& "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --remote-debugging-port=9222 --user-data-dir="$env:TEMP\edge-cdp-profile" about:blank

Then connect:

browser = p.chromium.connect_over_cdp("http://127.0.0.1:9222")

API surface

  • sync_playwright(...)
  • async_playwright(...)
  • p.chromium.launch(...)
  • p.chromium.connect_over_cdp(endpoint)
  • p.firefox.launch(...)
  • browser.new_context(...)
  • browser.new_page()
  • page.goto(url, wait_until="load", timeout=...)
  • page.content()
  • browser.close()

Environment variables

  • PLAYWRONG_PREFER_OPEN (true/false)
  • PLAYWRONG_CDP_ENDPOINTS (comma-separated URLs)
  • PLAYWRONG_CDP_TIMEOUT_SECONDS (float)
  • PLAYWRONG_VERBOSE (true/false)

Notes

  • Edge-compatible target creation uses PUT /json/new?url=... because modern Edge returns 405 on GET /json/new.
  • Firefox attach-to-existing-session is not supported; Firefox launches a new WebDriver session.
  • This package intentionally exposes a minimal subset rather than full Playwright parity.

Legal Responsibility

This library is distributed as a general-purpose automation toolkit.

  • The maintainers/publishers of playwrong do not grant permission to access any specific website, service, or data source.
  • Compliance with laws, contracts, robots policies, terms of service, and internal security/privacy requirements is solely the responsibility of the user/operator.
  • Users are responsible for obtaining any required authorization before automating browser actions.
  • The software is provided under the project license on an "AS IS" basis, without legal or compliance warranties.

See SECURITY.md for reporting and security policy 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

playwrong-0.1.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

playwrong-0.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file playwrong-0.1.0.tar.gz.

File metadata

  • Download URL: playwrong-0.1.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for playwrong-0.1.0.tar.gz
Algorithm Hash digest
SHA256 736f50ca6122e9e4fed3a1d53d41bad9efe6b28d4e437ee528931c887448bf51
MD5 7771932daeb652257afee22873ba5a2a
BLAKE2b-256 be0ae1c2dd8e37d3d99da8ea2a485eae936eb9c0fbc551a6caf60d3f235abfae

See more details on using hashes here.

Provenance

The following attestation bundles were made for playwrong-0.1.0.tar.gz:

Publisher: publish-pypi.yml on lramos0/playwrong

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

File details

Details for the file playwrong-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: playwrong-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for playwrong-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 404c808ee91cf4c7e86efd267440312fb3aba349ff1b7ca9b9e67a26a4ee9750
MD5 66769b2cc9688d35c07dc022a97c430b
BLAKE2b-256 7d733b1418319c79f12e5aae9afa6566e1a86dd026a03243c77a84f03da9f067

See more details on using hashes here.

Provenance

The following attestation bundles were made for playwrong-0.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on lramos0/playwrong

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