Skip to main content

Generate Python Requests code from HAR file

Project description


  • Step 1: Interact with a website from your usual browser
  • Step 2: automatically generate the Python code to replay your requests


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!


  • Automatic requests code generation from a HAR file
  • Detection of the headers common to all requests and code factorization
  • Clever inference on the origin of authorization headers
  • Code formatting using black


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 >

To read from the clipboard:

pbpaste | har2requests - >

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 (it happens a lot).

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.


  • Use requests.Session
  • Handle cookies (e.g. with a session)
  • handle text field from post requests

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for har2requests, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size har2requests-0.1.3-py3-none-any.whl (6.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size har2requests-0.1.3.tar.gz (5.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page