我正在做PyQt5,我的版本是5.13。在文档中
webview = QWebEngineView()
agent = u"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246"
profile = QWebEngineProfile.setHttpUserAgent(agent)
webpage = QWebEnginePage(profile, webview)
webview.setPage(webpage)
webview.show()
根据上面的文档链接,用户代理字符串类型是Unicode,这是创建的,但是当我运行代码时,出现了错误
profile = QWebEngineProfile.setHttpUserAgent(agent)
TypeError: setHttpUserAgent(self, str): first argument of unbound method must have type 'QWebEngineProfile'
如何解决这种类型错误?据我所知,它们不是QWebEngineProfile类型的字符串
试试看:
相关问题 更多 >
编程相关推荐