| 20 | |
| 21 | |
| 22 | class Window(QWebView): |
| 23 | |
| 24 | def __init__(self, *args, **kwargs): |
| 25 | super(Window, self).__init__(*args, **kwargs) |
| 26 | self.resize(800, 600) |
| 27 | # 浏览器设置 |
| 28 | setting = QWebSettings.globalSettings() |
| 29 | setting.setAttribute(QWebSettings.PluginsEnabled, True) |
| 30 | # 解决xp下ssl问题 |
| 31 | self.page().networkAccessManager().sslErrors.connect(self.handleSslErrors) |
| 32 | sslconf = QSslConfiguration.defaultConfiguration() |
| 33 | clist = sslconf.caCertificates() |
| 34 | cnew = QSslCertificate.fromData(b"CaCertificates") |
| 35 | clist.extend(cnew) |
| 36 | sslconf.setCaCertificates(clist) |
| 37 | sslconf.setProtocol(QSsl.AnyProtocol) |
| 38 | QSslConfiguration.setDefaultConfiguration(sslconf) |
| 39 | |
| 40 | def handleSslErrors(self, reply, errors): |
| 41 | # 解决ssl错误 |
| 42 | reply.ignoreSslErrors() |
| 43 | |
| 44 | |
| 45 | if __name__ == '__main__': |