From anonymous, 1 Month ago, written in Python.
Embed
  1. import collections
  2.  
  3. from PyQt5.QtCore import QUrl, QTimer
  4. from PyQt5.QtWidgets import QApplication
  5. from PyQt5.QtWebEngineWidgets import QWebEnginePage, QWebEngineView
  6.  
  7.  
  8. class Page(QWebEnginePage):
  9.  
  10.     def __init__(self, urls, parent=None):
  11.         super().__init__(parent)
  12.         self.urls = collections.deque(urls)
  13.         self.loadFinished.connect(self.on_load_finished)
  14.  
  15.     def certificateError(self, error):
  16.         print(f"Certificate error: {error.errorDescription()}")
  17.         return False  # stop loading
  18.  
  19.     def on_load_finished(self, ok):
  20.         url = self.url()
  21.         assert url.isValid(), url
  22.         if ok:
  23.             print(f"Loaded successfully: {url.toDisplayString()}")
  24.         else:
  25.             print(f"Failed loading: {url.toDisplayString()}")
  26.         self.load_next_url()
  27.  
  28.     def load_next_url(self):
  29.         if not self.urls:
  30.             QApplication.instance().quit()
  31.             return
  32.  
  33.         url = self.urls.popleft()
  34.         print(f"Now loading: {url}")
  35.         qurl = QUrl(url)  # or QUrl.fromUserInput(url)
  36.         assert qurl.isValid(), url
  37.         self.load(qurl)
  38.  
  39.  
  40.  
  41. if __name__ == '__main__':
  42.     app = QApplication([])
  43.     urls = ['https://21cskills.africa', 'https://expired.badssl.com']
  44.  
  45.     page = Page(urls)
  46.     page.load_next_url()
  47.  
  48.     app.exec_()