如何使 Recaptcha 与 QWebView 一起工作

How to make Recaptcha work with QWebView

我试图让 PyQt4 查看需要验证码才能工作的网页,但它说浏览器不受支持。这是消息的屏幕截图:

有什么办法可以解决这个问题吗?

我能够通过 modifying the user-agent string 使其工作以包括受支持的浏览器之一:

import sys
from PyQt4 import QtCore, QtGui, QtWebKit

class WebPage(QtWebKit.QWebPage):
    def userAgentForUrl(self, url):
        return super(WebPage, self).userAgentForUrl(url) + ' Chrome'

class Window(QtWebKit.QWebView):
    def __init__(self):
        super(Window, self).__init__()
        self.setPage(WebPage(self))
        self.load(QtCore.QUrl('https://www.google.com/recaptcha/api2/demo'))

if __name__ == '__main__':

    app = QtGui.QApplication(sys.argv)
    window = Window()
    window.setGeometry(600, 100, 600, 900)
    window.show()
    sys.exit(app.exec_())