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

Uploaded Source

Built Distribution

playwright_har_tracer-0.3.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: playwright-har-tracer-0.3.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.9.7 Darwin/20.6.0

File hashes

Hashes for playwright-har-tracer-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d8c4b87c95a5bed76b7c9b73bf24b56fcd4075f8937300ee60d00b184c0a98c2
MD5 6bd00fd3c7feba0fd2d041dee3eb18e3
BLAKE2b-256 20f2d93a4a7c7bfdab67dec353a1aad293de6d04c5870b33d76a18d0bb3d6781

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for playwright_har_tracer-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b2227e5b091cdde26747e186d76087ec00379927879ff91f83d97c481ed58cf
MD5 09b092d10a7b695f2a0df6de17d7a4ca
BLAKE2b-256 dd55282bb05b223df56f89cf91cba69d16bed43628cd6e987a3641e3a891b122

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