Skip to main content

Generate Python Requests code from HAR file

Project description

har2requests

  • Step 1: Interact with a website from your usual browser

  • Step 2: automatically generate the Python code to replay your requests

Motivation

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!

Features

  • 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

Installation

pip install har2requests

Usage

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

TODO

  • 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.

Source Distribution

har2requests-0.1.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

har2requests-0.1.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file har2requests-0.1.1.tar.gz.

File metadata

  • Download URL: har2requests-0.1.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.32.1 CPython/3.6.7

File hashes

Hashes for har2requests-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2f40f3f06b4db93cd77999f7da1b36489ff8a74a951479f23eb878b2c7defc1c
MD5 282cdca2c50c638491ed9ec0b91d386b
BLAKE2b-256 29ca52d75eb81e9893674d3ce3bea075759e682b7b6a105131034bc2e89fa17d

See more details on using hashes here.

File details

Details for the file har2requests-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: har2requests-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.32.1 CPython/3.6.7

File hashes

Hashes for har2requests-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d4f4c4473de78ac1a675a109806158df1fc927005b10a4dd2e1797b0b27f70a3
MD5 a074f9f10efe8fc768db7c37788d2ea5
BLAKE2b-256 0e87ebcf0735b5dc6effb6744dec08ba3a7b9e2af2793e3edaabd9b6573f8da1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page