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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for playwright-har-tracer-0.3.1.tar.gz
Algorithm Hash digest
SHA256 92bb45891d3c6a8a83efe723fc6b7f16124000d3ce731a84082e4518312dc872
MD5 3c61577896c169e821003466f5adc326
BLAKE2b-256 6464e12fb1df98eb001ee69a6389ab05bddf29d04de17f943368b2ae9a9e2718

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for playwright_har_tracer-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ec0611067c26e43940d3e2000d1d3ce52e1a59e6b62b0447f1dd6fa9987d3f33
MD5 f9f56fb16669ad47bc595daed1494298
BLAKE2b-256 682085c4fa3d77518ff13b133e4f405b96deebdf38ff8a8e64373efbe43c601b

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