Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ninoseki/playwright-har-tracer
A Python implementation version of Playwright's HAR tracer
https://github.com/ninoseki/playwright-har-tracer
playwright
Last synced: 22 days ago
JSON representation
A Python implementation version of Playwright's HAR tracer
- Host: GitHub
- URL: https://github.com/ninoseki/playwright-har-tracer
- Owner: ninoseki
- License: mit
- Created: 2021-05-20T11:57:41.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-15T14:32:07.000Z (11 months ago)
- Last Synced: 2024-10-01T04:43:05.469Z (about 1 month ago)
- Topics: playwright
- Language: Python
- Homepage:
- Size: 456 KB
- Stars: 8
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# playwright-har-tracer
[![PyPI version](https://badge.fury.io/py/playwright-har-tracer.svg)](https://badge.fury.io/py/playwright-har-tracer)
[![Python CI](https://github.com/ninoseki/playwright-har-tracer/actions/workflows/test.yml/badge.svg)](https://github.com/ninoseki/playwright-har-tracer/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/ninoseki/playwright-har-tracer/badge.svg?branch=main)](https://coveralls.io/github/ninoseki/playwright-har-tracer?branch=main)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
```bash
pip install playwright-har-tracer
```## Usage
```python
import asyncio
from playwright.async_api import async_playwright
from playwright_har_tracer import HarTracerasync 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())
```