Skip to main content
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)
    ...

Release files for nonebot-plugin-requests 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nonebot-plugin-requests 0.1.4
File Size Uploaded
nonebot_plugin_requests-0.1.4.tar.gz 5.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nonebot-plugin-requests 0.1.4
File Interpreter ABI Platform
nonebot_plugin_requests-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 11.9 kB

Release files / nonebot_plugin_requests-0.1.4.tar.gz

Download URL nonebot_plugin_requests-0.1.4.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3a1f930dbec070c076eb5879e3465d04ae1803b4eee2c293388267fd2a61ff3c
BLAKE2b-256 checksum
How to use checksums
9ee02332953332a619d52867ed51647827715e3bcda6ca4519091bbbb4fd4c3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.4

Release files / nonebot_plugin_requests-0.1.4-py3-none-any.whl

Download URL nonebot_plugin_requests-0.1.4-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
193f7e62aab640f8223846a459d36713b021c643debe655125864ef00c03e72b
BLAKE2b-256 checksum
How to use checksums
71eacd7836017d596588d74eb586159cc5f1a4d12f6abeee85ceba5d11a65ac5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.4

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page