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

Uploaded Source

Built Distribution

playwright_har_tracer-0.1.3-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: playwright-har-tracer-0.1.3.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.2 Darwin/20.4.0

File hashes

Hashes for playwright-har-tracer-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6cc1fcd3c5d750301aada363374a6cb3b715513c9d1fc1f698425487e6b9cafa
MD5 af5bd2090cee564f0c6d0bca44178ff6
BLAKE2b-256 c243e5f1846cef01af86f9b6cf6f8df5e9a7082c527728bab3316830d77ba9fa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for playwright_har_tracer-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 84dae14e1cc9b65ecd4b3e399b8b3a6abc5feb7352e731548f33eb596ee18f7d
MD5 2f2d799b44d203ee95430afc6ba7425a
BLAKE2b-256 286f5c2193632c6dd1ec98958f298498b2e8ba2aa6fa6586b5fcabc27a766e9e

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