When I browse to a page using the following code, the result is in another language (Russian I think). When I browse to the same url in other browsers I get the English 404 page as expected. I tried setting the accept language, but that didn't help. What am I missing?
import sys
from PyQt5 import QtWidgets, QtCore
from PyQt5.QtWebEngineWidgets import QWebEngineView
app = QtWidgets.QApplication(sys.argv)
w = QWebEngineView()
w.page().profile().setHttpAcceptLanguage('en') # This doesn't help
w.load(QtCore.QUrl('http://turbobit.net/download')) # Goes to russian? 404 page
w.show()
app.exec_()
The following webkit version works as expected
import sys
from PyQt5 import QtWidgets, QtCore
from PyQt5.QtWebKitWidgets import QWebView
app = QtWidgets.QApplication(sys.argv)
w = QWebView()
w.setUrl(QtCore.QUrl('http://turbobit.net/download')) # Loads correct English 404 page
w.show()
app.exec_()
You need to set the language before creating the view:
import sys
from PyQt5 import QtWidgets, QtCore
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEngineProfile
app = QtWidgets.QApplication(sys.argv)
QWebEngineProfile.defaultProfile().setHttpAcceptLanguage('en')
w = QWebEngineView()
w.load(QtCore.QUrl('http://turbobit.net/download'))
w.show()
app.exec_()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.