|
1 | 1 | # Hario-Core: Modern HAR Parsing |
2 | 2 |
|
3 | 3 | [](https://badge.fury.io/py/hario-core) |
4 | | -[](https://github.com/v-pikulev/hario-core/actions/workflows/python-package.yml) |
| 4 | +[](https://github.com/pikulev/hario-core/actions/workflows/python-package.yml) |
5 | 5 | [](https://github.com/psf/black) |
6 | 6 |
|
7 | 7 | A modern, extensible, and type-safe Python library for parsing, transforming, and analyzing HAR (HTTP Archive) files. Built on Pydantic, Hario-Core provides robust validation, flexible transformation, and easy extension for custom HAR formats. |
@@ -40,44 +40,6 @@ for entry in results: |
40 | 40 | print(entry["id"], entry["request"]["url"]) |
41 | 41 | ``` |
42 | 42 |
|
43 | | -## Why Normalize HAR Data? |
44 | | - |
45 | | -HAR files from browsers or proxies sometimes contain negative values for sizes or timings (e.g., -1 for unknown). Normalization transforms these to zero, so you can safely compute totals, averages, and other metrics without skewing your analytics. This is especially important for dashboards, BI, and automated reporting. |
46 | | - |
47 | | -## Why Deterministic IDs? |
48 | | - |
49 | | -A deterministic ID is generated from key fields (like URL and timestamp), so the same logical request always gets the same ID—even if the HAR is re-exported or merged. This is essential for deduplication, change tracking, and building reliable analytics or data warehouses. |
50 | | - |
51 | | -## Extending: Supporting Custom HAR Formats |
52 | | - |
53 | | -You can use the built-in model for Chrome DevTools HAR extensions: |
54 | | - |
55 | | -```python |
56 | | -from hario_core.models.extensions.chrome_devtools import DevToolsEntry |
57 | | - |
58 | | -# Suppose entry_json is a dict from a Chrome DevTools HAR entry |
59 | | -entry = DevToolsEntry.model_validate(entry_json) |
60 | | -print(entry.resourceType, entry.request.url) |
61 | | -``` |
62 | | - |
63 | | -You can also register your own Pydantic models for browser-specific or proprietary HAR extensions: |
64 | | - |
65 | | -```python |
66 | | -from hario_core import register_entry_model |
67 | | -from hario_core.models.har_1_2 import Entry |
68 | | -from pydantic import Field |
69 | | - |
70 | | -class SafariEntry(Entry): |
71 | | - webkit_trace: dict = Field(alias="_webkitTrace") |
72 | | - |
73 | | -def is_safari_entry(entry_json): |
74 | | - return "_webkitTrace" in entry_json |
75 | | - |
76 | | -register_entry_model(is_safari_entry, SafariEntry) |
77 | | -``` |
78 | | - |
79 | | -> **Note:** The `_webkitTrace` field is not part of the official Safari HAR format. This example is for demonstration purposes only, showing how to extend the model for custom fields. |
80 | | -
|
81 | 43 | ## Documentation |
82 | 44 |
|
83 | 45 | - [API Reference](docs/api.md) |
|
0 commit comments