the python sdk for baidu
Project description
百度sdk
安装
pip install baidu-api
文档
# 授权认证
>>> from baidu.client import BaiduClient
>>> client = BaiduClient(app_id=<你的appid>, api_key=<你的apikey>, secret_key=<你的secretkey>)
# 调用接口
>>> from baidu.api import TextCensor
>>> result, detail = TextCensor(client).is_allowed("在线阅读色情小说,在线赌博,枪支弹药购买: https://iqiyi.com")
>>> result == "rejected"
True
使用redis缓存access_token
from redis import Redis
from baidu.session.redisstorage import RedisStorage
redis_client = Redis.from_url("redis://localhost:6379/0")
session_interface = RedisStorage(redis_client, prefix="baiduapi")
baidu_client = BaiduClient(app_id, api_key, secret_key,
session=session_interface)
感谢
- 里面的session是模仿的wechatpy的session
贡献代码
欢迎提交pr, 我一定会尽早地处理. 不用在乎什么格式, 写代码就是勇敢地提交, 上线. 出错了再修改, 回滚就可以了啊.
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
baidu-api-0.0.2.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for baidu_api-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 676d970db29a86bc037e1edaa735e04d8ce3ab2038f773f12a7c6ec75975f5c9 |
|
MD5 | d2c5d08e9ec3562d7a0faef78db3fb80 |
|
BLAKE2b-256 | 0079f88498dfdbb1cb1e2bd349d62928a85312568aa970f107c6c1a996e1f58b |