whatsapp web loading issue for QWebEngineView
Unsolved
Qt for Python
-
So i have ask this question a few days ago and i have had an answer from @JonB and the solution works quite well just by switching the user agent.credits to JonB,but there is this one issure remain and that is if i refresh the page,or if i log out from the whatsapp after login the problem comes back,tho one thing for sure the user agent have changed because i print out the user agent.i have a video(link) and code with some explaination clipped with this question to make things more clear.
import sys from PySide6.QtCore import QUrl from PySide6.QtWidgets import * from PySide6.QtWebEngineWidgets import QWebEngineView class Widgets(QMainWindow): def __init__(self): QMainWindow.__init__(self) self.setWindowTitle("Simple Web Browser") self.widget = QWidget(self) self.webview = QWebEngineView() #change the user agent self.webview.page().profile().setHttpUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.5414.75 Safari/537.36") #the link to whatsapp web self.webview.load(QUrl("https://web.whatsapp.com/")) self.check_button = QPushButton("Refesh") self.check_button.clicked.connect(self.button_clicked) self.toplayout = QHBoxLayout() self.toplayout.addWidget(self.check_button) self.layout = QVBoxLayout() self.layout.addLayout(self.toplayout) self.layout.addWidget(self.webview) self.widget.setLayout(self.layout) self.setCentralWidget(self.widget) def button_clicked(self): #reload the webpage self.webview.reload() #print out the user agent print(self.webview.page().profile().httpUserAgent()+"\n") if __name__ == "__main__": app = QApplication(sys.argv) window = Widgets() window.show() sys.exit(app.exec())
-
What exactly do you want to achieve here? I'm not sure I understand what the problem is.