What Is The Default User-agent Of Pyqt Web Kit Qwebview And How To Get It
i am new to python and developing a GUI in PyQt which has a Web Browser. I want to show the User-Agent going with the Url but not founding a way.my code is - class Manager(QNetwor
Solution 1:
A User-Agent
is something which gets send to the server. This information is not sent from the server.
To set a user agent you can do the following with your Manager
class for example:
from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkRequest
manager = Manager()
request = QNetworkRequest(QUrl("http://www.google.com/"))
request.setRawHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1")
manager.get(request)
And modify your def _finished(self, reply):
method to get the request with the User-Agent
:
def_finished(self, reply):
print reply.request().rawHeader("User-Agent")
Post a Comment for "What Is The Default User-agent Of Pyqt Web Kit Qwebview And How To Get It"