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 在线手册
Metadata
Release files for curl-to-json 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| curl_to_json-0.1.0.tar.gz | 4.3 kB | Without provenance | Details for curl_to_json-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| curl_to_json-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for curl_to_json-0.1.0-py3-none-any.whl |
Total release size: 9.5 kB
Release files / curl_to_json-0.1.0.tar.gz
| Download URL | curl_to_json-0.1.0.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
467270f94e7aab2af71e927fd6e310b1ee0cdabaa380b53bdf7607bc30c37f26
|
|
BLAKE2b-256 checksum How to use checksums |
df93bae9a22b311b067e421a2ee29ce3594de687ec00ca1973fd632c5adee24d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.8.18 Darwin/24.1.0
|
Release files / curl_to_json-0.1.0-py3-none-any.whl
| Download URL | curl_to_json-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
413ca8999f9dc4d2fe00607bd1d1cd58791ae0f8b10ddb56f38975999a4f9eff
|
|
BLAKE2b-256 checksum How to use checksums |
8f919ac26fe51e5821d75287657c97c06c0cbb0350faef12b7158a6cc54810ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.8.18 Darwin/24.1.0
|
Security for curl-to-json 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.