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.

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

Uploaded Source

Built Distribution

playwright_har_tracer-0.1.1-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for playwright-har-tracer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9b32ffbd58138aa6959bd43d85156eac318f4d670a67f29cab62991df6938ea8
MD5 77875608c01baeede74f02c1ecfc72f6
BLAKE2b-256 3940b0dfdee47b8182a4c95ca4457965f4189303b17bc17d4abfec56a0805ce4

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for playwright_har_tracer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a8a8ab68c7c6d6c07e2a9fb184abcff7c18dcc448260efae652bd7f9fb519763
MD5 57d627bfd02ff73a7f08bc67ffc52474
BLAKE2b-256 49f04003b036db6ce2976f5032c16f8422da99d3b45687643fa3a3fa1e128ffc

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