Updated example for PyQt5 (the magic is to reimplement the acceptNavigationRequest method):
from PyQt5 import QtWidgets, QtCore, QtGui, QtWebEngineWidgets class RestrictedQWebEnginePage(QtWebEngineWidgets.QWebEnginePage): """ Filters links so that users cannot just navigate to any page on the web, but just to those pages, that are listed in allowed_pages. This is achieved by re-implementing acceptNavigationRequest. The latter could also be adapted to accept, eg URLs within a domain.""" def __init__(self, parent=None): super().__init__(parent) self.allowed_pages = [] def acceptNavigationRequest(self, qurl, navtype, mainframe):
bst
source share