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.3.2.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

playwright_har_tracer-0.3.2-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: playwright-har-tracer-0.3.2.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.8.6 Darwin/21.2.0

File hashes

Hashes for playwright-har-tracer-0.3.2.tar.gz
Algorithm Hash digest
SHA256 0cf133ae1716e0d2e927623e31bf7883f9de944c7ffbd7ac149825e3f6e825c4
MD5 67358466f90cc24f9df341fbc8425974
BLAKE2b-256 3bbe5766003ec3e4d2f4a9bb9c05bea0519d2b9aacb8f9b276ee01e39d361713

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for playwright_har_tracer-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c1f826261ee72910a835eb7274edbb75526b83128ab4a565d08a36603c22400d
MD5 a542464cec50f0f85de8eba7143eeda7
BLAKE2b-256 58434cfe96005623e21d8b511908ea1cf902ff8c39e0af9e48a41df76ed68d4a

See more details on using hashes here.

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