WebviewRevise


NameWebviewRevise JSON
Version 0.0.6 PyPI version JSON
download
home_pagehttps://github.com/r0x0r/pywebview
Summary这是一个 pywebview 修改版本
upload_time2024-06-27 20:16:02
maintainerNone
docs_urlNone
authorCC
requires_python>=3.7
licenseBSD 3-Clause License Copyright (c) 2014-2017, Roman Sirokov All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords webviewrevise webview webview pywebview
VCS
bugtrack_url
requirements pythonnet pyobjc-core pyobjc-framework-Cocoa pyobjc-framework-Quartz pyobjc-framework-WebKit pyobjc-framework-Security PyQt5 pyqtwebengine QtPy importlib_resources proxy_tools bottle cryptography
Travis-CI No Travis.
coveralls test coverage No coveralls.
            =============
WebviewRevise
=============

WebviewRevise 是一个基于 PyWebView 5.1 版本的修改版本,集成了网络拦截功能(该功能目前仅支持 EdgeChromium 作为后端引擎)。

概述
----

PyWebView 是一个轻量级的跨平台库,用于在 Python 应用程序中创建和控制 Webview 窗口。本项目在原有的基础上进行了扩展,添加了网络拦截功能,允许开发者拦截和修改通过 Webview 发送的网络请求。

特性
----

- 基于 PyWebView 5.1。
- 网络拦截功能,允许开发者:
    - 拦截 HTTP 请求和响应。
    - 修改请求头和响应头。
- 允许开发者自己控制CoreWebView2。
    - 只需要继承filter,在 do 方法中设置即可

安装
----

使用 pip 安装 WebviewRevise :

.. code-block:: bash

    pip install WebviewRevise

请注意,由于本项目是 PyWebView 的修改版本,可能需要从源代码安装或使用特定的安装步骤。

使用示例
--------

以下是一个简单的使用示例,展示如何创建一个带有网络拦截功能的 Webview 窗口:

.. code-block:: python

    import webview
    from webview.platforms.edgechromium import DoSomething,filter,WebView2Core
    from webview.platforms.winforms import BrowserMap

    class net(filter):
        def do(self, edgeChrome, sender, args):
            # 开启请求过滤
            sender.CoreWebView2.AddWebResourceRequestedFilter("*", WebView2Core.CoreWebView2WebResourceContext.All) # *:表示所有
            # 网络请求拦截回调设置
            sender.CoreWebView2.WebResourceRequested += self.on_web_resource_requested # 设置回调函数

        def on_web_resource_requested(self, sender, args):
            """网络请求拦截回调函数:
                如果需要修改请求或响应,可以在这里进行操作

            Args:
                sender (_type_): Microsoft.Web.WebView2.Core.CoreWebView2 对象
                args (_type_): Microsoft.Web.WebView2.Core.CoreWebView2WebResourceRequestedEventArgs对象
            """        
            # 例如,打印请求的 URI
            print(args.Request.Uri)
            # 详情请参照 Microsoft.Web.WebView2 如何使用

   
    if __name__ == '__main__':
        # 创建 Webview 窗口并设置网络请求拦截器
        DoSomething.append(net())
        window = webview.create_window('Simple browser',"src/index.html")
        window.is_filter = True # 默认开启过滤拦截
        webview.start()

贡献
----

我们欢迎任何形式的贡献,包括但不限于:

- 报告问题或错误。
- 提供功能请求或改进建议。

许可证
------

本项目采用 Modified BSD 许可证。有关更多信息,请查看 `LICENSE` 文件。

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/r0x0r/pywebview",
    "name": "WebviewRevise",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "WebviewRevise, Webview, webview, pywebview",
    "author": "CC",
    "author_email": "3204604858@qq.com",
    "download_url": "https://files.pythonhosted.org/packages/d1/91/d6edfb9bcd29e5b3946f60cb45ba53de7e13e426cb1ea836e79956a58447/webviewrevise-0.0.6.tar.gz",
    "platform": "Windows",
    "description": "=============\r\nWebviewRevise\r\n=============\r\n\r\nWebviewRevise \u662f\u4e00\u4e2a\u57fa\u4e8e PyWebView 5.1 \u7248\u672c\u7684\u4fee\u6539\u7248\u672c\uff0c\u96c6\u6210\u4e86\u7f51\u7edc\u62e6\u622a\u529f\u80fd(\u8be5\u529f\u80fd\u76ee\u524d\u4ec5\u652f\u6301 EdgeChromium \u4f5c\u4e3a\u540e\u7aef\u5f15\u64ce)\u3002\r\n\r\n\u6982\u8ff0\r\n----\r\n\r\nPyWebView \u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684\u8de8\u5e73\u53f0\u5e93\uff0c\u7528\u4e8e\u5728 Python \u5e94\u7528\u7a0b\u5e8f\u4e2d\u521b\u5efa\u548c\u63a7\u5236 Webview \u7a97\u53e3\u3002\u672c\u9879\u76ee\u5728\u539f\u6709\u7684\u57fa\u7840\u4e0a\u8fdb\u884c\u4e86\u6269\u5c55\uff0c\u6dfb\u52a0\u4e86\u7f51\u7edc\u62e6\u622a\u529f\u80fd\uff0c\u5141\u8bb8\u5f00\u53d1\u8005\u62e6\u622a\u548c\u4fee\u6539\u901a\u8fc7 Webview \u53d1\u9001\u7684\u7f51\u7edc\u8bf7\u6c42\u3002\r\n\r\n\u7279\u6027\r\n----\r\n\r\n- \u57fa\u4e8e PyWebView 5.1\u3002\r\n- \u7f51\u7edc\u62e6\u622a\u529f\u80fd\uff0c\u5141\u8bb8\u5f00\u53d1\u8005\uff1a\r\n    - \u62e6\u622a HTTP \u8bf7\u6c42\u548c\u54cd\u5e94\u3002\r\n    - \u4fee\u6539\u8bf7\u6c42\u5934\u548c\u54cd\u5e94\u5934\u3002\r\n- \u5141\u8bb8\u5f00\u53d1\u8005\u81ea\u5df1\u63a7\u5236CoreWebView2\u3002\r\n    - \u53ea\u9700\u8981\u7ee7\u627ffilter,\u5728 do \u65b9\u6cd5\u4e2d\u8bbe\u7f6e\u5373\u53ef\r\n\r\n\u5b89\u88c5\r\n----\r\n\r\n\u4f7f\u7528 pip \u5b89\u88c5 WebviewRevise \uff1a\r\n\r\n.. code-block:: bash\r\n\r\n    pip install WebviewRevise\r\n\r\n\u8bf7\u6ce8\u610f\uff0c\u7531\u4e8e\u672c\u9879\u76ee\u662f PyWebView \u7684\u4fee\u6539\u7248\u672c\uff0c\u53ef\u80fd\u9700\u8981\u4ece\u6e90\u4ee3\u7801\u5b89\u88c5\u6216\u4f7f\u7528\u7279\u5b9a\u7684\u5b89\u88c5\u6b65\u9aa4\u3002\r\n\r\n\u4f7f\u7528\u793a\u4f8b\r\n--------\r\n\r\n\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f7f\u7528\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u521b\u5efa\u4e00\u4e2a\u5e26\u6709\u7f51\u7edc\u62e6\u622a\u529f\u80fd\u7684 Webview \u7a97\u53e3\uff1a\r\n\r\n.. code-block:: python\r\n\r\n    import webview\r\n    from webview.platforms.edgechromium import DoSomething,filter,WebView2Core\r\n    from webview.platforms.winforms import BrowserMap\r\n\r\n    class net(filter):\r\n        def do(self, edgeChrome, sender, args):\r\n            # \u5f00\u542f\u8bf7\u6c42\u8fc7\u6ee4\r\n            sender.CoreWebView2.AddWebResourceRequestedFilter(\"*\", WebView2Core.CoreWebView2WebResourceContext.All) # *:\u8868\u793a\u6240\u6709\r\n            # \u7f51\u7edc\u8bf7\u6c42\u62e6\u622a\u56de\u8c03\u8bbe\u7f6e\r\n            sender.CoreWebView2.WebResourceRequested += self.on_web_resource_requested # \u8bbe\u7f6e\u56de\u8c03\u51fd\u6570\r\n\r\n        def on_web_resource_requested(self, sender, args):\r\n            \"\"\"\u7f51\u7edc\u8bf7\u6c42\u62e6\u622a\u56de\u8c03\u51fd\u6570:\r\n                \u5982\u679c\u9700\u8981\u4fee\u6539\u8bf7\u6c42\u6216\u54cd\u5e94\uff0c\u53ef\u4ee5\u5728\u8fd9\u91cc\u8fdb\u884c\u64cd\u4f5c\r\n\r\n            Args:\r\n                sender (_type_): Microsoft.Web.WebView2.Core.CoreWebView2 \u5bf9\u8c61\r\n                args (_type_): Microsoft.Web.WebView2.Core.CoreWebView2WebResourceRequestedEventArgs\u5bf9\u8c61\r\n            \"\"\"        \r\n            # \u4f8b\u5982\uff0c\u6253\u5370\u8bf7\u6c42\u7684 URI\r\n            print(args.Request.Uri)\r\n            # \u8be6\u60c5\u8bf7\u53c2\u7167 Microsoft.Web.WebView2 \u5982\u4f55\u4f7f\u7528\r\n\r\n   \r\n    if __name__ == '__main__':\r\n        # \u521b\u5efa Webview \u7a97\u53e3\u5e76\u8bbe\u7f6e\u7f51\u7edc\u8bf7\u6c42\u62e6\u622a\u5668\r\n        DoSomething.append(net())\r\n        window = webview.create_window('Simple browser',\"src/index.html\")\r\n        window.is_filter = True # \u9ed8\u8ba4\u5f00\u542f\u8fc7\u6ee4\u62e6\u622a\r\n        webview.start()\r\n\r\n\u8d21\u732e\r\n----\r\n\r\n\u6211\u4eec\u6b22\u8fce\u4efb\u4f55\u5f62\u5f0f\u7684\u8d21\u732e\uff0c\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e\uff1a\r\n\r\n- \u62a5\u544a\u95ee\u9898\u6216\u9519\u8bef\u3002\r\n- \u63d0\u4f9b\u529f\u80fd\u8bf7\u6c42\u6216\u6539\u8fdb\u5efa\u8bae\u3002\r\n\r\n\u8bb8\u53ef\u8bc1\r\n------\r\n\r\n\u672c\u9879\u76ee\u91c7\u7528 Modified BSD \u8bb8\u53ef\u8bc1\u3002\u6709\u5173\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u67e5\u770b `LICENSE` \u6587\u4ef6\u3002\r\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause License  Copyright (c) 2014-2017, Roman Sirokov All rights reserved.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.  * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.",
    "summary": "\u8fd9\u662f\u4e00\u4e2a pywebview \u4fee\u6539\u7248\u672c",
    "version": "0.0.6",
    "project_urls": {
        "Homepage": "https://github.com/r0x0r/pywebview"
    },
    "split_keywords": [
        "webviewrevise",
        " webview",
        " webview",
        " pywebview"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f98b255acf87eb5220f71e3255b6deaa6dfc9d444a78172eb3eb623f1d955628",
                "md5": "6a3fc5b2e9def7c97d18c1d43b1852f0",
                "sha256": "9e33a08e7f446cdac2dc4d2c3fddcfe03e41be229b79588097e0735540c8bc7c"
            },
            "downloads": -1,
            "filename": "WebviewRevise-0.0.6-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6a3fc5b2e9def7c97d18c1d43b1852f0",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.7",
            "size": 448169,
            "upload_time": "2024-06-27T20:15:28",
            "upload_time_iso_8601": "2024-06-27T20:15:28.857304Z",
            "url": "https://files.pythonhosted.org/packages/f9/8b/255acf87eb5220f71e3255b6deaa6dfc9d444a78172eb3eb623f1d955628/WebviewRevise-0.0.6-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d191d6edfb9bcd29e5b3946f60cb45ba53de7e13e426cb1ea836e79956a58447",
                "md5": "211223d1e8e2d86ac578dc6fa3c80fc3",
                "sha256": "ab705f8ac637dd5b3426918bcdfae86af179c68b7130f886dd5a445d2379539c"
            },
            "downloads": -1,
            "filename": "webviewrevise-0.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "211223d1e8e2d86ac578dc6fa3c80fc3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 431897,
            "upload_time": "2024-06-27T20:16:02",
            "upload_time_iso_8601": "2024-06-27T20:16:02.969459Z",
            "url": "https://files.pythonhosted.org/packages/d1/91/d6edfb9bcd29e5b3946f60cb45ba53de7e13e426cb1ea836e79956a58447/webviewrevise-0.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-27 20:16:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "r0x0r",
    "github_project": "pywebview",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "appveyor": true,
    "requirements": [
        {
            "name": "pythonnet",
            "specs": []
        },
        {
            "name": "pyobjc-core",
            "specs": []
        },
        {
            "name": "pyobjc-framework-Cocoa",
            "specs": []
        },
        {
            "name": "pyobjc-framework-Quartz",
            "specs": []
        },
        {
            "name": "pyobjc-framework-WebKit",
            "specs": []
        },
        {
            "name": "pyobjc-framework-Security",
            "specs": []
        },
        {
            "name": "PyQt5",
            "specs": []
        },
        {
            "name": "pyqtwebengine",
            "specs": []
        },
        {
            "name": "QtPy",
            "specs": []
        },
        {
            "name": "importlib_resources",
            "specs": []
        },
        {
            "name": "proxy_tools",
            "specs": []
        },
        {
            "name": "bottle",
            "specs": []
        },
        {
            "name": "cryptography",
            "specs": []
        }
    ],
    "lcname": "webviewrevise"
}
        
CC
Elapsed time: 0.27936s