我在 PyQt5 代码中遇到错误。谁能帮我。import sysfrom PyQt5.QtWidgets import QApplicationfrom PyQt5.QtCore import QUrlfrom PyQt5.QtWebEngineWidgets import QWebEngineView as QWebViewclass Browser(QWebView): def __init__(self): QWebView.__init__(self) self.loadFinished.connect(self._result_available) def _result_available(self, ok): frame = self.page().mainFrame() print( unicode(frame.toHtml()).encode('utf-8'))if __name__ == '__main__': app = QApplication(sys.argv) view = Browser() view.load(QUrl('http://www.google.com')) app.exec_()输出:[错误] AttributeError Traceback (most recent call last) <ipython-input-50-e1b5f3fc9054> in _result_available(self, ok) 13 14 def _result_available(self, ok): ---> 15 frame = self.page().mainFrame() ------------- [ERROR] 16 print( unicode(frame.toHtml()).encode('utf-8')) 17 AttributeError: 'QWebEnginePage' object has no attribute 'mainFrame'
添加回答
举报
0/150
提交
取消