To write bots in Python, the two main options are:
Of course, requests bots are more stable but they require more daunting work to reverse engineer the javascript code and reproduce every request made by the client.
Discover har2requests!
pip install har2requests
From Chrome or Firefox, go to the Network tab of the Developer Tools, put the filters you want and export to HAR.
To read from a file:
har2requests input.har > output.py
To read from the clipboard:
pbpaste | har2requests - > output.py
By default, OPTIONS requests are ignored. To include them, use --include-options
.
When encountering errors, you can use the --unsafe
feature that will display warnings
instead of errors if the HAR file does not fit the specification.
har2requests
uses string matching algorithms to find the origin of authorization headers. If your file is too big, it might be slow. You can disable it with --no-infer
.
--exclude-cookie-headers
avoids the need to manually edit the output if all cookies are assigned by the website each session (the common scenario).--generate-assertions
helps pinpoint unexpected variations quickly.--debug-requests
helps if you need to debug the requests/responses themselves.Version | Tag | Published |
---|---|---|
0.2.3 | 1yr ago | |
0.2.2 | 1yr ago | |
0.2.1 | 2yrs ago | |
0.2.0 | 2yrs ago |