Skip to main content

No project description provided

Project description

NoneBotPluginLogo

NoneBotPluginText

nonebot_plugin_requests

✨ 封装 ForwardDriver 实现 HttpClient 功能 ✨

📖 介绍

本插件提供了 HttpClient 的封装, 简化了网络请求调用

💿 安装

使用 nb-cli 安装 在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
nb plugin install nonebot-plugin-requests
使用包管理器安装 在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
pip
pip install nonebot-plugin-requests
pdm
pdm add nonebot-plugin-requests
poetry
poetry add nonebot-plugin-requests
conda
conda install nonebot-plugin-requests

打开 nonebot2 项目根目录下的 pyproject.toml 文件, 在 [tool.nonebot] 部分追加写入

plugins = ["nonebot_plugin_example"]

⚙️ 配置

环境配置

在 nonebot2 项目的.env文件中为 nonebot2 配置 ForwardDriver 驱动器

配置参考 nonebot2 文档

# 使用 fastapi + aiohttp 驱动器
DRIVER=~fastapi+~aiohttp

# 使用 fastapi + httpx + websockets 驱动器
DRIVER=~fastapi+~httpx+~websockets

插件可选配置

在 nonebot2 项目的.env文件中添加下表中的配置

配置项 必填 默认值 说明
nonebot_plugin_requests_enable_proxy False 是否使用代理
nonebot_plugin_requests_proxy_type http 代理类型(仅限http)
nonebot_plugin_requests_proxy_address 127.0.0.1 代理地址
nonebot_plugin_requests_proxy_port 1081 代理端口

🎉 使用

参考示例如下:

import nonebot

nonebot.require("nonebot_plugin_requests")

from nonebot_plugin_requests import NonebotRequests


async def get_something():
    request = NonebotRequests()
    response = await request.get(...)

    json = NonebotRequests.parse_content_json(response)
    text = NonebotRequests.parse_content_text(response)
    ...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonebot_plugin_requests-0.1.4.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

nonebot_plugin_requests-0.1.4-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_requests-0.1.4.tar.gz.

File metadata

File hashes

Hashes for nonebot_plugin_requests-0.1.4.tar.gz
Algorithm Hash digest
SHA256 3a1f930dbec070c076eb5879e3465d04ae1803b4eee2c293388267fd2a61ff3c
MD5 954f3695e6ba3a53629ee9e37d53e166
BLAKE2b-256 9ee02332953332a619d52867ed51647827715e3bcda6ca4519091bbbb4fd4c3e

See more details on using hashes here.

File details

Details for the file nonebot_plugin_requests-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_requests-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 193f7e62aab640f8223846a459d36713b021c643debe655125864ef00c03e72b
MD5 425698f8a3f0917cda4372c7a200e858
BLAKE2b-256 71eacd7836017d596588d74eb586159cc5f1a4d12f6abeee85ceba5d11a65ac5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page