YouthLearning / XXQG

一个自动完成学习强国每日任务的插件
MIT License
12 stars 3 forks source link

请问浏览器地址填写范例 #1

Open wdssfff00 opened 4 months ago

wdssfff00 commented 4 months ago

环境为Ubuntu24.4,安装有gnome图形UI,py3.10.14 转自AI: 根据您提供的日志信息,您在尝试使用Playwright启动Chromium浏览器实例时遇到了问题。错误信息显示,Playwright尝试启动一个有头(headed)的浏览器实例,但没有运行X服务器。在Ubuntu 22.04 LTS上,Chromium等浏览器通常需要X服务器来显示图形界面。由于您的环境中没有运行X服务器,浏览器启动失败,导致TargetClosedError。

debug日志:08-08 01:12:47 [SUCCESS] nonebot | OneBot V11 | [message.group.normal]: Message -2147446475 from @[群:] '开始学习' 08-08 01:12:47 [DEBUG] nonebot | Running PreProcessors... 08-08 01:12:47 [DEBUG] nonebot | Checking for matchers in priority 1... 08-08 01:12:47 [DEBUG] nonebot | Checking for matchers in priority 50... 08-08 01:12:48 [INFO] nonebot | Event will be handled by Matcher(type='message', module=XXQG.utils.handle, lineno=25) 08-08 01:12:48 [DEBUG] nonebot | Running Matcher(type='message', module=XXQG.utils.handle, lineno=25) 08-08 01:12:48 [DEBUG] nonebot | Running handler Dependent(call=startStudy) 08-08 01:12:48 [DEBUG] nonebot | OneBot V11 | Calling API send_msg 08-08 01:12:49 [INFO] nonebot | Matcher(type='message', module=XXQG.utils.handle, lineno=25) running complete 08-08 01:12:49 [ERROR] nonebot | Running Matcher(type='message', module=XXQG.utils.handle, lineno=25) failed. Traceback (most recent call last): File "", line 21, in File "/usr/local/python-3.10.13/lib/python3.10/site-packages/nonebot/init.py", line 335, in run get_driver().run(*args, **kwargs) File "/usr/local/python-3.10.13/lib/python3.10/site-packages/nonebot/drivers/fastapi.py", line 186, in run uvicorn.run( File "/usr/local/python-3.10.13/lib/python3.10/site-packages/uvicorn/main.py", line 577, in run server.run() File "/usr/local/python-3.10.13/lib/python3.10/site-packages/uvicorn/server.py", line 65, in run return asyncio.run(self.serve(sockets=sockets)) File "/usr/local/python-3.10.13/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/local/python-3.10.13/lib/python3.10/site-packages/nonebot/message.py", line 476, in check_and_run_matcher await _run_matcher(

File "/usr/local/python-3.10.13/lib/python3.10/site-packages/nonebot/message.py", line 428, in _run_matcher await matcher.run(bot, event, state, stack, dependency_cache) File "/usr/local/python-3.10.13/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 850, in run await self.simple_run(bot, event, state, stack, dependency_cache) File "/usr/local/python-3.10.13/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 825, in simple_run await handler( File "/usr/local/python-3.10.13/lib/python3.10/site-packages/nonebot/dependencies/init.py", line 94, in call return await cast(Callable[..., Awaitable[R]], self.call)(**values) File "/usr/local/python-3.10.13/lib/python3.10/site-packages/XXQG/utils/handle.py", line 212, in startStudy status = await startTask(user.uid) File "/usr/local/python-3.10.13/lib/python3.10/site-packages/XXQG/utils/activity.py", line 643, in startTask browser = await p.chromium.launch_persistent_context( File "/usr/local/python-3.10.13/lib/python3.10/site-packages/playwright/async_api/_generated.py", line 14377, in launch_persistent_context await self._impl_obj.launch_persistent_context( File "/usr/local/python-3.10.13/lib/python3.10/site-packages/playwright/_impl/_browser_type.py", line 157, in launch_persistent_context from_channel(await self._channel.send("launchPersistentContext", params)), File "/usr/local/python-3.10.13/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 59, in send return await self._connection.wrap_api_call( File "/usr/local/python-3.10.13/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 514, in wrap_api_call raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None playwright._impl._errors.TargetClosedError: BrowserType.launch_persistent_context: Target page, context or browser has been closed Browser logs:

╔════════════════════════════════════════════════════════════════════════════════════════════════╗ ║ Looks like you launched a headed browser without having a XServer running. ║ ║ Set either 'headless: true' or use 'xvfb-run ' before running Playwright. ║ ║ ║ ║ <3 Playwright Team ║ ╚════════════════════════════════════════════════════════════════════════════════════════════════╝ Call log:

/usr/bin/google-chrome --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,HttpsUpgrades,PaintHolding --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --unsafely-disable-devtools-self-xss-warnings --no-sandbox --disable-extensions-except=/usr/local/python-3.10.13/lib/python3.10/site-packages/XXQG/resource --load-extension=/usr/local/python-3.10.13/lib/python3.10/site-packages/XXQG/resource --user-data-dir=/home/0学习/0青年大学习/xxqg/data/xxqg/browser --remote-debugging-pipe about:blank - pid=1762492 - [pid=1762492][err] [1762492:1762492:0808/011249.605564:ERROR:ozone_platform_x11.cc(244)] Missing X server or $DISPLAY - [pid=1762492][err] [1762492:1762492:0808/011249.605659:ERROR:env.cc(258)] The platform failed to initialize. Exiting. - [pid=1762492] - [pid=1762492] starting temporary directories cleanup - [pid=1762492] finished temporary directories cleanup 08-08 01:12:49 [DEBUG] nonebot | Checking for matchers completed
wdssfff00 commented 3 months ago

系统装有图形版edge和谷歌浏览器 local_browser_path="/usr/bin/google-chrome" # 本地浏览器程序路径 仅支持谷歌浏览器和Edge浏览器