Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/s1m0n38/har2py
Convert .har file in python requests scripts
https://github.com/s1m0n38/har2py
chrome-devtools converter har jinja2 networking requests selenium
Last synced: 2 months ago
JSON representation
Convert .har file in python requests scripts
- Host: GitHub
- URL: https://github.com/s1m0n38/har2py
- Owner: S1M0N38
- License: mit
- Created: 2020-11-28T23:30:52.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-10-25T21:02:35.000Z (over 2 years ago)
- Last Synced: 2023-05-01T13:53:44.601Z (almost 2 years ago)
- Topics: chrome-devtools, converter, har, jinja2, networking, requests, selenium
- Language: Python
- Homepage:
- Size: 24.8 MB
- Stars: 6
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# har2py
When browsing the web with the Developer Tools open you can record the Network
Activities (requests perform by your browser & responses you get from servers).
Then you can export all these data into an [HAR](https://en.wikipedia.org/wiki/HAR_(file_format))
file (Http ARchive). With **har2py** you can convert HAR file into valid python
code that reproduce the requests perform by your browser.## Installation
Just a simple pip install, i.e. `python3 -m pip install har2py`
## Usage
1. Navigate the web with your browser while recording your activity. Then save the
data in HAR file. Here is an example with Chrome Devs Tools
![har.gif](https://github.com/S1M0N38/har2py/blob/main/har.gif?raw=true)2. Go to the directory where is located the har file you want to convert and
type```har2py my_har_file.har```
This will generate valid python code base on [requests](https://requests.readthedocs.io/en/master/)
library from *my_har_file.har*. The generated file will be called
*my_har_file.py* and be located in the same directory of the input file.Additional arguemnts are describe in the help
```
> har2py -h
usage: har2py [-h] [-o OUTPUT] [-t TEMPLATE] [-f FILTERS] [-w] input
positional arguments:
input har input fileoptional arguments:
-h, --help show this help message and exit
-o OUTPUT, --output OUTPUT
py output file. If not the define use the same name of the har
file with py extension.
-t TEMPLATE, --template TEMPLATE
jinja2 template used to generate py code. Default to requests.
(For now "requests" is the only available template)
-f FILTERS, --filters FILTERS
commas value separeted string of the resource type you want to
include in py generated code. Supported type are `xhr`,
`script`, `stylesheet`, `image`, `font`, `document`, `other`.
Default to xhr,document,other.
-w, --overwrite overwrite py file if one previous py file with the same name
already exists.```
## Similar projects
I like to develope my own program so I can extend easly by adding new jinja2 templates.
In the past I use this other projects and from them I have been ispired to build
har2py.- [curlconverter](https://github.com/NickCarneiro/curlconverter):
Convert cURL syntax to native Python, Go, PHP, JavaScript, R, Elixir and Dart
HTTP code
- [har2requests](https://github.com/louisabraham/har2requests):
Generate Python Requests code from your browser activity