增加百度一下,补上漏了的依赖

This commit is contained in:
CMHopeSunshine 2022-09-25 17:40:13 +08:00
parent d5e9ffd890
commit b4fb8d0441
3 changed files with 39 additions and 30 deletions

View File

@ -1,9 +1,9 @@
from nonebot import on_command from nonebot import on_command
from nonebot.params import CommandArg from nonebot.params import CommandArg
from nonebot.adapters.onebot.v11 import Message, MessageEvent from nonebot.adapters.onebot.v11 import Message, MessageEvent, MessageSegment
from nonebot.plugin import PluginMetadata from nonebot.plugin import PluginMetadata
from LittlePaimon.utils.brower import AsyncPlaywright from LittlePaimon.utils.brower import get_browser
__plugin_meta__ = PluginMetadata( __plugin_meta__ = PluginMetadata(
name='实用工具', name='实用工具',
@ -18,17 +18,42 @@ __plugin_meta__ = PluginMetadata(
screenshot_cmd = on_command('网页截图', priority=10, block=True, state={ screenshot_cmd = on_command('网页截图', priority=10, block=True, state={
'pm_name': '网页截图', 'pm_name': '网页截图',
'pm_description': '对指定链接页面进行截图【网页截图www.baidu.com】,可选指定网页元素', 'pm_description': '对指定链接页面进行截图【网页截图www.baidu.com】',
'pm_usage': '网页截图<链接> [元素]', 'pm_usage': '网页截图<链接>',
'pm_priority': 1 'pm_priority': 1
}) })
baidu_cmd = on_command('百度一下', priority=10, block=True, state={
'pm_name': '百度一下',
'pm_description': '百度一下,你就知道',
'pm_usage': '百度一下<关键词>',
'pm_priority': 2
})
@screenshot_cmd.handle() @screenshot_cmd.handle()
async def _(event: MessageEvent, msg: Message = CommandArg()): async def _(event: MessageEvent, msg: Message = CommandArg()):
await screenshot_cmd.send('正在尝试截图,请稍等...') await screenshot_cmd.send('正在尝试截图,请稍等...')
msg = msg.extract_plain_text().strip().split(' ') url = msg.extract_plain_text().split(' ')[0]
url = msg[0] brower = await get_browser()
element = msg[1:] if len(msg) > 1 else None page = await brower.new_page()
img = await AsyncPlaywright.screenshot(url, element=element) await page.goto(url, wait_until='networkidle')
await screenshot_cmd.finish(img) if page is None:
await screenshot_cmd.finish('截图失败,无法访问该网页')
img = await page.screenshot(full_page=True)
await screenshot_cmd.finish(MessageSegment.image(img))
@baidu_cmd.handle()
async def _(event: MessageEvent, msg: Message = CommandArg()):
await baidu_cmd.send('正在为你百度,请稍等...')
keyword = msg.extract_plain_text()
brower = await get_browser()
page = await brower.new_page()
await page.goto(f'https://www.baidu.com/s?wd={keyword}', wait_until='networkidle', timeout=10000)
if page is None:
await baidu_cmd.finish('百度失败,请稍后再试')
context = await page.query_selector('#content_left')
img = await context.screenshot()
await baidu_cmd.finish(MessageSegment.image(img))

25
poetry.lock generated
View File

@ -1018,7 +1018,7 @@ reference = "ali"
[[package]] [[package]]
name = "pypinyin" name = "pypinyin"
version = "0.46.0" version = "0.47.1"
description = "汉字拼音转换模块/工具." description = "汉字拼音转换模块/工具."
category = "main" category = "main"
optional = false optional = false
@ -1721,19 +1721,6 @@ type = "legacy"
url = "https://mirrors.aliyun.com/pypi/simple" url = "https://mirrors.aliyun.com/pypi/simple"
reference = "ali" reference = "ali"
[[package]]
name = "xlsxwriter"
version = "3.0.3"
description = "A Python module for creating Excel XLSX files."
category = "main"
optional = false
python-versions = ">=3.4"
[package.source]
type = "legacy"
url = "https://mirrors.aliyun.com/pypi/simple"
reference = "ali"
[[package]] [[package]]
name = "yarl" name = "yarl"
version = "1.8.1" version = "1.8.1"
@ -1771,7 +1758,7 @@ reference = "ali"
[metadata] [metadata]
lock-version = "1.1" lock-version = "1.1"
python-versions = "^3.8" python-versions = "^3.8"
content-hash = "1503804589e3563a5cd206853bd2f9098246b21fd281a48353b4eef22da14fde" content-hash = "70d8154b21fe4bda3fcbd7dcdc2d0fa3d35ab84bdd7b7484c87712a6a2e31e54"
[metadata.files] [metadata.files]
aiofiles = [ aiofiles = [
@ -2516,8 +2503,8 @@ pypika-tortoise = [
{file = "pypika_tortoise-0.1.6-py3-none-any.whl", hash = "sha256:2d68bbb7e377673743cff42aa1059f3a80228d411fbcae591e4465e173109fd8"}, {file = "pypika_tortoise-0.1.6-py3-none-any.whl", hash = "sha256:2d68bbb7e377673743cff42aa1059f3a80228d411fbcae591e4465e173109fd8"},
] ]
pypinyin = [ pypinyin = [
{file = "pypinyin-0.46.0-py2.py3-none-any.whl", hash = "sha256:7251f4fa0b1e43ad91f6121d9a842e8acd72a6a34deea5e87d2a97621eadc11f"}, {file = "pypinyin-0.47.1-py2.py3-none-any.whl", hash = "sha256:8b9a2de91958b61c649e823877de4005630cdca8f7b9537fe0d65740f42a07a5"},
{file = "pypinyin-0.46.0.tar.gz", hash = "sha256:0d2e41e95dbc20a232c0f5d3850654eebbfcba303d96358d2c46592725bb989c"}, {file = "pypinyin-0.47.1.tar.gz", hash = "sha256:4244eec898294fd099c02d59faf8e89106d83d74e1c04a7af59094664d89636b"},
] ]
python-dateutil = [ python-dateutil = [
{file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"},
@ -2938,10 +2925,6 @@ win32-setctime = [
{file = "win32_setctime-1.1.0-py3-none-any.whl", hash = "sha256:231db239e959c2fe7eb1d7dc129f11172354f98361c4fa2d6d2d7e278baa8aad"}, {file = "win32_setctime-1.1.0-py3-none-any.whl", hash = "sha256:231db239e959c2fe7eb1d7dc129f11172354f98361c4fa2d6d2d7e278baa8aad"},
{file = "win32_setctime-1.1.0.tar.gz", hash = "sha256:15cf5750465118d6929ae4de4eb46e8edae9a5634350c01ba582df868e932cb2"}, {file = "win32_setctime-1.1.0.tar.gz", hash = "sha256:15cf5750465118d6929ae4de4eb46e8edae9a5634350c01ba582df868e932cb2"},
] ]
xlsxwriter = [
{file = "XlsxWriter-3.0.3-py3-none-any.whl", hash = "sha256:df0aefe5137478d206847eccf9f114715e42aaea077e6a48d0e8a2152e983010"},
{file = "XlsxWriter-3.0.3.tar.gz", hash = "sha256:e89f4a1d2fa2c9ea15cde77de95cd3fd8b0345d0efb3964623f395c8c4988b7f"},
]
yarl = [ yarl = [
{file = "yarl-1.8.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:abc06b97407868ef38f3d172762f4069323de52f2b70d133d096a48d72215d28"}, {file = "yarl-1.8.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:abc06b97407868ef38f3d172762f4069323de52f2b70d133d096a48d72215d28"},
{file = "yarl-1.8.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:07b21e274de4c637f3e3b7104694e53260b5fc10d51fb3ec5fed1da8e0f754e3"}, {file = "yarl-1.8.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:07b21e274de4c637f3e3b7104694e53260b5fc10d51fb3ec5fed1da8e0f754e3"},

View File

@ -32,6 +32,7 @@ scipy = "^1.9.1"
scikit-learn = "^1.1.2" scikit-learn = "^1.1.2"
shapely = "^1.8.4" shapely = "^1.8.4"
gitpython = "^3.1.27" gitpython = "^3.1.27"
pypinyin = "^0.47.1"
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
nb-cli = "^0.6.7" nb-cli = "^0.6.7"