Convert curl command to json data
Project description
Trans curl request to json data
将参数转化为json 的时候尽量使用 -- 之后的值,作为字典的键。 这个库的目的是将curl 发送请求的参数转化为json 格式,方便在python 中使用。
curl 功能很强大,支持的参数也很多,这里只做了部分的解析
重点放在curl HTTP发送请求的方面.
其他一些特性,--ipv4,--ipv6,本地文件读取,指定dns 寻址服务器 DoH,ftp 等协议暂未支持
支持的参数
-
-X,--request支持的请求方法, -
--http2是否使用http2 协议 默认为否 -
-d,--data支持, 支持在一行命令中多次使用-d参数,此时HTTP 请求头中Content-Type : application/x-www-form-urlencoded使用该参数,请求自动转化为POST.
-
-H,--header添加HTTP请求头,支持多行 -
-I,--head发送HEAD请求,并打印header,支持 -
-s,--silent, 不输出任何东西,只返回HTTP 头 -
-v,--verbose输出通信的整个过程,用于调试 -
-b,--cookiecookie 支持多个-b 参数,不支持文件读取 -
-A,--user-agent设置User-Agent,curl 默认的User-Agent 为 curl/version,本项目默认为空 -
--compressed是否压缩请求 -
-k,--insecure允许不验证服务器的证书 -
-u,--user用户名:密码 -
-L,--location允许自动跟随重定向 -
-I,--include打印头信息 -
-x,--proxy使用代理 代理 格式为:hostname:port,如果没有scheme 默认使用http -
-U,--proxy-user代理用户名密码 ,格式为:username:password 如果有会自动将账号密码添加到代理url 中 -
-u,--userbasic 认证,格式为:username:password,输出为headers 中的Authorization -
--connect-timeout连接超时时间 -
--referer请求头中的referer
usage
- 命令行中使用
python -m curl_to_json curl_to_json curl -X GET http://example.com
- 也可以直接使用
curl_to_json curl -X GET http://example.com
- 也可以使用 以下格式
curl_to_json "curl -X GET http://example.com"
- 在python 代码中使用
from curl_to_json import parse
cmd = 'curl -X GET http://example.com'
print(parse(cmd))
Reference
1. curl 的用法指南
3. Uncurl
4. curl 在线手册
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file curl_to_json-0.1.0.tar.gz.
File metadata
- Download URL: curl_to_json-0.1.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.8.18 Darwin/24.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
467270f94e7aab2af71e927fd6e310b1ee0cdabaa380b53bdf7607bc30c37f26
|
|
| MD5 |
c17c7cdd9d67c1f2e20c8e24186bded9
|
|
| BLAKE2b-256 |
df93bae9a22b311b067e421a2ee29ce3594de687ec00ca1973fd632c5adee24d
|
File details
Details for the file curl_to_json-0.1.0-py3-none-any.whl.
File metadata
- Download URL: curl_to_json-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.8.18 Darwin/24.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
413ca8999f9dc4d2fe00607bd1d1cd58791ae0f8b10ddb56f38975999a4f9eff
|
|
| MD5 |
11693abb2899a4959d2c12cf5a79bb9c
|
|
| BLAKE2b-256 |
8f919ac26fe51e5821d75287657c97c06c0cbb0350faef12b7158a6cc54810ea
|