j0lv3r4 / curlparser

Parse cURL commands returning object representing the request.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cURL Parser

Tests Coverage Pypi Package version

Parse cURL commands returning object representing the request.

How to install?

curlparser is available on PyPi:

Using pip

$ pip install curlparser

Using poetry

$ poetry add curlparser

Using pipenv

$ pipenv install curlparser

How to use?

>>> import curlparser

>>> result = curlparser.parse(
    """
    curl \
      --header 'Content-Type: application/json' \
      --request PUT \
      --user nlecoy:my_password \
      --data '{"username":"xyz", "password":"xyz"}' \
      https://api.github.com/repos/nlecoy/curlparser
    """
)

>>> result.url
'https://api.github.com/repos/nlecoy/curlparser'

>>> result.auth
('nlecoy', 'my_password')

>>> result.json
{'username': 'xyz', 'password': 'xyz'}

Available parameters

curlparser's parse method will return a ParsedCommand object containing the following fields:

  • method
  • url
  • auth
  • cookies
  • data
  • json
  • header
  • verify

License

cURL Parser is distributed under the Apache 2.0. See LICENSE for more information.

About

Parse cURL commands returning object representing the request.

License:Apache License 2.0


Languages

Language:Python 100.0%