def __init__(self, log, confirm_callback=None, prompt_callback=None, user_agent=USER_AGENT, enable_developer_tools=False, parent=None): QWebPage.__init__(self, parent) self.log = log self.user_agent = user_agent if user_agent else USER_AGENT self.confirm_callback = confirm_callback self.prompt_callback = prompt_callback self.setForwardUnsupportedContent(True) self.unsupportedContent.connect(self.on_unsupported_content) settings = self.settings() if enable_developer_tools: settings.setAttribute(QWebSettings.DeveloperExtrasEnabled, True) QWebSettings.enablePersistentStorage( os.path.join(cache_dir(), 'webkit-persistence')) QWebSettings.setMaximumPagesInCache(0) self.bridge_name = 'b' + uuid.uuid4().get_hex() self.mainFrame().javaScriptWindowObjectCleared.connect( self.add_window_objects) self.dom_loaded = False
def __init__(self, reactor, downloader, global_options): super().__init__() self._reactor = reactor self.downloader = downloader self.options = global_options QWebSettings.setObjectCacheCapacities(0, 0, 0) QWebSettings.setMaximumPagesInCache(0) self._windows = None
def initUI(self): self.setMinimumSize(300, 300) # self.TextEdit = QtWidgets.QTextEdit(self) # self.TextEdit.setMinimumSize(300, 300) # self.TextEdit.setReadOnly(True) # self.load(QtCore.QUrl('file:///'+os.getcwd()+"/generated_html/index.html")) QWebSettings.setMaximumPagesInCache(0) QWebSettings.setObjectCacheCapacities(0, 0, 0)
def __init__(self, log, confirm_callback=None, prompt_callback=None, user_agent=USER_AGENT, enable_developer_tools=False, parent=None): QWebPage.__init__(self, parent) self.log = log self.user_agent = user_agent if user_agent else USER_AGENT self.confirm_callback = confirm_callback self.prompt_callback = prompt_callback self.setForwardUnsupportedContent(True) self.unsupportedContent.connect(self.on_unsupported_content) settings = self.settings() if enable_developer_tools: settings.setAttribute(QWebSettings.DeveloperExtrasEnabled, True) QWebSettings.enablePersistentStorage(os.path.join(cache_dir(), 'webkit-persistence')) QWebSettings.setMaximumPagesInCache(0) self.bridge_name = 'b' + uuid.uuid4().get_hex() self.mainFrame().javaScriptWindowObjectCleared.connect( self.add_window_objects) self.dom_loaded = False
'css-media-type': (MapType.setter, lambda qws, v: qws.setCSSMediaType(v)), #'accelerated-compositing': # (MapType.attribute, QWebSettings.AcceleratedCompositingEnabled), #'tiled-backing-store': # (MapType.attribute, QWebSettings.TiledBackingStoreEnabled), }, 'storage': { 'offline-storage-database': (MapType.attribute, QWebSettings.OfflineStorageDatabaseEnabled), 'offline-web-application-storage': (MapType.attribute, QWebSettings.OfflineWebApplicationCacheEnabled), 'local-storage': (MapType.attribute, QWebSettings.LocalStorageEnabled), 'maximum-pages-in-cache': (MapType.static_setter, lambda v: QWebSettings.setMaximumPagesInCache(v)), 'object-cache-capacities': (MapType.static_setter, lambda v: QWebSettings.setObjectCacheCapacities(*v)), 'offline-storage-default-quota': (MapType.static_setter, lambda v: QWebSettings.setOfflineStorageDefaultQuota(v)), 'offline-web-application-cache-quota': (MapType.static_setter, lambda v: QWebSettings.setOfflineWebApplicationCacheQuota(v)), }, 'general': { 'private-browsing': (MapType.attribute, QWebSettings.PrivateBrowsingEnabled), 'developer-extras': (MapType.attribute, QWebSettings.DeveloperExtrasEnabled),
#'accelerated-compositing': # (MapType.attribute, QWebSettings.AcceleratedCompositingEnabled), #'tiled-backing-store': # (MapType.attribute, QWebSettings.TiledBackingStoreEnabled), }, 'storage': { 'offline-storage-database': (MapType.attribute, QWebSettings.OfflineStorageDatabaseEnabled), 'offline-web-application-storage': (MapType.attribute, QWebSettings.OfflineWebApplicationCacheEnabled), 'local-storage': (MapType.attribute, QWebSettings.LocalStorageEnabled), 'maximum-pages-in-cache': (MapType.static_setter, lambda v: QWebSettings.setMaximumPagesInCache(v)), 'object-cache-capacities': (MapType.static_setter, lambda v: QWebSettings.setObjectCacheCapacities(*v)), 'offline-storage-default-quota': (MapType.static_setter, lambda v: QWebSettings.setOfflineStorageDefaultQuota(v)), 'offline-web-application-cache-quota': (MapType.static_setter, lambda v: QWebSettings.setOfflineWebApplicationCacheQuota(v)), }, 'general': { 'private-browsing': (MapType.attribute, QWebSettings.PrivateBrowsingEnabled), 'developer-extras': (MapType.attribute, QWebSettings.DeveloperExtrasEnabled),