MCPcopy Create free account
hub / github.com/PyQt5/PyQt / interceptRequest

Method interceptRequest

QWebEngineView/BlockRequestData.py:43–48  ·  view source on GitHub ↗
(self, info)

Source from the content-addressed store, hash-verified

41class 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
51class Window(QWebEngineView):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected