python webbrowser模块和file://协议查询字符串

发布于 2025-02-05 23:35:15 字数 500 浏览 2 评论 0原文

我有一个使用铬嵌入式框架的应用程序。 作为CEF不可用的设置的替代方法(例如,Python 3.10+),我想退缩到WebBrowser来启动本地WebApp。

由于没有CEF,我没有任何挂钩将数据传递到WebApp,因此我尝试通过GET参数传递配置字符串。我不知道为什么,但是当我将一个与文件一起使用时,查询字符串消失了://协议

示例:

webbrowser.open_new_tab('https://google.com?foo=bar')  # this works.
webbrowser.open_new_tab('file:///c:/some/dir/somefile.html?foo=bar')  # this doesn't works.

在第二个示例上。打开浏览器窗口,地址栏中的URL是file> file> file> file>://some/dir/somefile.html

有什么想法吗?

I have an application that uses Chromium Embedded Framework.
As an alternative for a setup where CEF is not usable (Python 3.10+ for example), I would like to fallback to a webbrowser to launch a local webapp.

Since I don't have any hook to pass data to the webapp without CEF, I tried to pass a configuration string through a GET parameter. I don't know why, but the query string disappears when I use one with the file:// protocol

example :

webbrowser.open_new_tab('https://google.com?foo=bar')  # this works.
webbrowser.open_new_tab('file:///c:/some/dir/somefile.html?foo=bar')  # this doesn't works.

on the second example. A browser window is open and the URL in the address bar is file:///c:/some/dir/somefile.html

Any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文