Skip to main content

A Python implementation version of Playwright's HAR tracer

Project description

playwright-har-tracer

PyPI version Python CI Coverage Status

A Python implementation version of Playwright's HAR tracer. It is equivalent to playwright v0.13.x’s HAR tracer implementation.

Motivation

Playwright's HAR tracer is implemented to generate HAR as a file. I need to get HAR as a Python object rather than a file.

  • playwright-har-tracer's HarTracer generates HAR as a dataclass object.

⚠️ Limitations

  • Tested with Python 3.8+
  • Tested with Chromium only
  • Supports the async API only

Installation

pip install playwright-har-tracer

Usage

import asyncio
from playwright.async_api import async_playwright
from playwright_har_tracer import HarTracer


async def main():
    async with async_playwright() as p:
        browser = await p.chromium.launch()
        context = await browser.new_context()

        tracer = HarTracer(context=context, browser_name=p.chromium.name)

        page = await context.new_page()

        await page.goto("http://whatsmyuseragent.org/")

        har = await tracer.flush()

        await context.close()
        await browser.close()

    print(har.to_json())


asyncio.run(main())

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

playwright-har-tracer-0.2.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

playwright_har_tracer-0.2.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file playwright-har-tracer-0.2.0.tar.gz.

File metadata

  • Download URL: playwright-har-tracer-0.2.0.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.9.6 Darwin/20.4.0

File hashes

Hashes for playwright-har-tracer-0.2.0.tar.gz
Algorithm Hash digest
SHA256 44934fc17afda5539673317ecdcb1abccdbe21358b1a4b0762c444c586d6dd5b
MD5 68da1fc19c954d3d31f1590565e3a4bb
BLAKE2b-256 3c08e193da666f2b6c3e63c56487f7f4ea9b3826b23e028978e537c0c3fc002a

See more details on using hashes here.

Provenance

File details

Details for the file playwright_har_tracer-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for playwright_har_tracer-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9b9ac6a064beb96b6ffe582faad4e84dc7335133dbe131a2f439edafbdbe942
MD5 c2fa98f6eda29c03f1c5cdf29709ea58
BLAKE2b-256 f80754be5293d65b92cef26c20d367f8959a2f8047e8a05f56cea5e1ada1c10c

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page