Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. whatsapp web loading issue for QWebEngineView
Forum Updated to NodeBB v4.3 + New Features

whatsapp web loading issue for QWebEngineView

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 378 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 1 Offline
    1 Offline
    101 Wizard
    wrote on last edited by
    #1

    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())
    

    video link here

    1 Reply Last reply
    0
    • Ard_FlamingoA Offline
      Ard_FlamingoA Offline
      Ard_Flamingo
      wrote on last edited by
      #2

      What exactly do you want to achieve here? I'm not sure I understand what the problem is.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved