Parse cURL commands returning object representing the request.
curlparser
is available on PyPi:
$ pip install curlparser
$ poetry add curlparser
$ pipenv install curlparser
>>> 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'}
curlparser
's parse method will return a ParsedCommand
object containing the following fields:
- method
- url
- auth
- cookies
- data
- json
- header
- verify
cURL Parser is distributed under the Apache 2.0. See LICENSE for more information.