python - 空白页面和错误,只有一个特定的 url,在 python 中使用 pyqt webview
问题描述
仅将以下代码与特定 URL 一起使用时,我遇到了问题:
import sys
from PyQt4.QtGui import QApplication
from PyQt4.QtCore import QUrl
from PyQt4.QtWebKit import QWebView,QWebSettings
class Browser(QWebView):
def __init__(self):
QWebView.__init__(self)
Settings = self.settings()
Settings.setAttribute(QWebSettings.JavascriptEnabled, True)
Settings.setAttribute(QWebSettings.JavaEnabled, True)
Settings.setAttribute(QWebSettings.PluginsEnabled, True)
Settings.setAttribute(QWebSettings.AutoLoadImages, True)
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()
from_url=True
url_to_view='https://www.twitch.tv/'
if from_url==True:
view.load(QUrl(url_to_view))
view.show()
app.exec_()
运行此代码时,我得到一个空白页和此错误:
QNetworkReplyImplPrivate::error: Internal problem, this method must only be called once.
QNetworkReplyImplPrivate::error: Internal problem, this method must only be called once.
这很奇怪,因为我只在https://www.twitch.tv/网址上遇到了这个问题。我曾尝试用https://www.google.com或其他任何东西替换 url,它工作正常。
我期待它与python2
and相关,但是在运行和实现PyQt4
时我遇到了同样的问题python3
PyQt5
有人可以帮助我用 pyqt 正确加载页面吗?
解决方案
推荐阅读
- php - 如何使用安全规范发出 Soap 请求
- python-3.x - 尝试从 python 写入 cassandra 时 CQL 查询中的语法错误
- java - 引用变量 DataOutputStream 和 FileOutputStream
- ios - 无法将“字符”类型的值分配给“字符串”类型?
- android - 带有 RecyclerView 顶部和按钮视图的 ConstraintLayout 某些部分是不可见的。
- maven - 如何dockerize一个多模块springboot应用程序?
- typescript - React Native 如何在断点上下文中执行代码
- firebase - Firebase 部署不更新内容
- python - AttributeError:“用户”对象没有属性“is_active”烧瓶应用程序
- asp.net-mvc - 需要帮助将第三个参数传递给复合页面上的 4 个部分视图