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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: playwright-har-tracer-0.1.2.tar.gz
  • Upload date:
  • Size: 8.1 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.2.tar.gz
Algorithm Hash digest
SHA256 5f7443a3e3c31ba97def5c7d46013620b43fab0ed383a35dbc32adbbb3b75add
MD5 dbbb364ef2f6a9b9513405e505bddad3
BLAKE2b-256 1af2093019eb0ad09ae2cf3b90bedc49a7a0b737f80a391968e35056d2646d04

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for playwright_har_tracer-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b35d61127b74ed5ac504e6403129c19896481c84ff0a8edd69ddeaa0b4732fd6
MD5 6973995653a14a75f1b1c8b633429352
BLAKE2b-256 f6dea7a0a06577d9b86f6f9da61b1b02fecd1769fc68ae2d5fd9ba923e17fe12

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page