安装
pip install cocoman
使用
演示
do 方法
- 参数跟
requests的参数保持一致 - 默认自带
重试、ua - 请求失败时,可以通过
raise_request_error参数选择不抛出异常
发送GET请求
- do 方法默认是 GET 请求,默认自带ua
from cocoman import Spider
s = Spider()
url = "https://www.baidu.com"
res = s.do(url)
title = res.xpath("//title/text()").get()
print(title)
发送POST请求
- do 方法传递了 data 或者 json 参数则是 POST 请求
from pprint import pprint
from cocoman import Spider
s = Spider()
api = "https://httpbin.org/post"
form_data = {"type": "请求表单"}
res = s.do(api, data=form_data)
pprint(res.json())
json_body = {"type": "JSON请求体"}
res = s.do(api, json=json_body)
pprint(res.json())
Metadata
Release files for cocoman 0.6.3
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 |
|---|---|---|---|---|
| cocoman-0.6.3.tar.gz | 10.8 kB | Without provenance | Details for cocoman-0.6.3.tar.gz |
Release files / cocoman-0.6.3.tar.gz
| Download URL | cocoman-0.6.3.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1cc735042c774f59f4019c69301d108d127f2b547ce5d860405f81d136bb6a16
|
|
BLAKE2b-256 checksum How to use checksums |
d32cb87d06bacb8198b899bcb1791d23b382f76eaffd0ec03f14c17d2fce7e2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.10
|
Security for cocoman 0.6.3
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.