| 39 | |
| 40 | |
| 41 | class RequestInterceptor(QWebEngineUrlRequestInterceptor): |
| 42 | |
| 43 | def interceptRequest(self, info): |
| 44 | url = info.requestUrl().toString() |
| 45 | # 这里演示只是拦截所有png图片,可自由发挥比如拦截js文件,修改后再返回 |
| 46 | if url.endswith('.png'): |
| 47 | # 原理在于重定向到自己的url协议里 |
| 48 | info.redirect(QUrl('myurl://png')) |
| 49 | |
| 50 | |
| 51 | class Window(QWebEngineView): |