如何在python中获取通过PyQt4 QWebView加载进行的请求的状态码?

时间:2018-08-26 23:35:13

标签: python request pyqt4 qwebview

我正在用PyQt4做一些实验并加载Web页面,我有类似的东西:

def __init__(self):
    self.app = QApplication(sys.argv)
    QWebView.__init__(self)
    self._loaded = False
    self.loadFinished.connect(self._loadFinished)

def load(self, url):
    self.load(QUrl(url))
    self.wait_load()
    frame = self.page().mainFrame()
    print "Loaded!"

def wait_load(self, delay=0):
    # process app events until page loaded
    while not self._loaded:
        self.app.processEvents()
        time.sleep(delay)
    self._loaded = False

def _loadFinished(self, result):
    self._loaded = True

如何获取“加载”功能上发出的请求的状态码?

我有一个使用lib“ requests”的先前版本,但发出了2个请求。

谢谢!

0 个答案:

没有答案