print out all the requested URLs during loading a web page

  • In my project, there is some need to get a certain requested URL during loading a web page,
    requested URLs in Chrome Dev Tools
    I think get the URL by Qt WebEngine is a good solution. I started by trying to use the code below to print out all the requested URLs during loading a web page, but it didn't work - no URL get printed at all , so what's wrong here ? Any good solutions ?

    import sys
    import os
    from PyQt5.QtWidgets import QApplication
    from PyQt5.QtWebEngineWidgets import *
    from PyQt5.QtWebEngineCore import *
    from PyQt5.QtCore import QUrl
    class WebEngineUrlRequestInterceptor(QWebEngineUrlRequestInterceptor):
        def __init__(self, parent=None):
        def interceptRequest(self, info):
    if __name__ == '__main__':
        app = QApplication(sys.argv)
        profile = QWebEngineProfile()
        page = QWebEnginePage(profile)
        view = QWebEngineView()
        view.resize(1024, 600)

  • maybe you should overwrite QWebEngineUrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
    qDebug()<<info.requestMethod() <<" "<<info.requestUrl()

Log in to reply