跳转到主要内容

"PRAW 4+的低级通信层。

项目描述

Latest prawcore Version Supported Python Versions PyPI - Downloads - Monthly GitHub Actions Status Coveralls Coverage OpenSSF Scorecard Contributor Covenant pre-commit Black code style

prawcore是PRAW 4+使用的低级通信层。

安装

使用pip通过以下方式安装prawcore

pip install prawcore

执行示例

以下示例演示了如何使用prawcore通过脚本应用程序类型获取指定用户的奖杯列表。此示例假设您已将环境变量PRAWCORE_CLIENT_IDPRAWCORE_CLIENT_SECRET设置为应用程序的相应值。

#!/usr/bin/env python
import os
import pprint
import prawcore

authenticator = prawcore.TrustedAuthenticator(
    prawcore.Requestor("YOUR_VALID_USER_AGENT"),
    os.environ["PRAWCORE_CLIENT_ID"],
    os.environ["PRAWCORE_CLIENT_SECRET"],
)
authorizer = prawcore.ReadOnlyAuthorizer(authenticator)
authorizer.refresh()

with prawcore.session(authorizer) as session:
    pprint.pprint(session.request("GET", "/api/v1/user/bboe/trophies"))

将上述内容保存为trophies.py,然后执行

python trophies.py

更多示例可在以下位置找到: https://github.com/praw-dev/prawcore/tree/main/examples

依赖于prawcore

prawcore 遵循语义版本控制,但有一个例外,即弃用不会在次要版本发布之前进行。本质上,预期只有主要版本会对 prawcore 的公共接口进行破坏性更改。因此,如果您依赖于 prawcore,则最好不仅指定您的包需要的 prawcore 的最小版本,还要限制主要版本。

以下是您可能想要指定 prawcore 依赖关系的两个示例

setup.py

setup(..., install_requires=["prawcore >=0.1, <1"], ...)

requirements.txt

prawcore >=1.5.1, <2

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

prawcore-2.4.0.tar.gz (15.9 kB 查看哈希值)

上传时间 源代码

构建分发

prawcore-2.4.0-py3-none-any.whl (17.2 kB 查看哈希值)

上传时间 Python 3

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面