The HAR file is an open file format for archiving HTTP packets.
You can find a lot of tools available to analyze, visualize HAR files.
Today I will show you how to use the analyzer python module to show info about your website.
This python module contains two classes for analyzing web pages based on a HAR file.
I install this python module using pip3.4 under Python 3.4.1 version.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | C:\Python34\Scripts\pip3.4.exe install haralyzer Collecting haralyzer Using cached haralyzer-1.4.3.tar.gz Collecting cached-property (from haralyzer) Using cached cached_property-1.2.0-py2.py3-none-any.whl Requirement already satisfied (use --upgrade to upgrade): numpy in c:\python34\lib\site-packages (from haralyzer) ... Building wheels for collected packages: haralyzer Running setup.py bdist_wheel for haralyzer Stored in directory: ... Successfully built haralyzer Installing collected packages: cached-property, haralyzer Successfully installed cached-property-1.2.0 haralyzer-1.4.3 |
I used one online free tool to create a test.har, file.
I put this file under Python3.4 folder and I test it.
The script I used is this:
1 2 3 4 5 6 7 8 9 10 11 | import json from haralyzer import HarParser, HarPage with open('test_dev.har', 'r') as f: har_parser = HarParser(json.loads(f.read())) print (har_parser.browser) # {u'name': u'Firefox', u'version': u'25.0.1'} for page in har_parser.pages: assert isinstance(page, HarPage) |
And this is the output of this script :
1 2 | C:\Python34>python.exe har_test.py {'version': '39.0.3', 'name': 'Firefox'} |