[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] QtWebEngineProfile and http user agent
From:       me () alandmoore ! com
Date:       2015-07-24 16:25:28
Message-ID: 38402.72.237.174.2.1437755128.squirrel () 67 ! 228 ! 73 ! 20
[Download RAW message or body]

I'm working on porting a QtWebkit based project
(http://github.com/alandmoore/wcgbrowser) to QtWebEngine
(http://github.com/alandmoore/admbrowser).

With pyqt5.5 released, I'm attempting to get custom user-agent strings
working.  If I understand the documentation correctly, I should be able to
set this in the QWebEnginePage's QWebEngineProfile, like in the snippet
below.


Unfortunatley, it doesn't seem to work, and the default agent is both
printed to stdout and sent to the server.

What am I doing wrong?  I'm using pyqt5.5 on python 3.4.3 on Arch Linux.

## START SNIPPET

from PyQt5.QtCore import QUrl
from PyQt5.QtWebEngineWidgets import (
    QWebEnginePage, QWebEngineView, QWebEngineProfile)
from PyQt5.QtWidgets import QApplication
import sys


class MyBrowser(QWebEngineView):

    def __init__(self):
        super(MyBrowser, self).__init__()

        profile = QWebEngineProfile()
        profile.setHttpUserAgent("test browser")
        page = QWebEnginePage(profile)
        self.setPage(page)
        print(
            '''Set user agent "{}"'''
            .format(
                self.page().profile().httpUserAgent()
            )
        )

app = QApplication(sys.argv)
m = MyBrowser()
m.show()
m.load(QUrl(sys.argv[1]))
app.exec_()

## END SNIPPET


_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic