From 78f23db2113d1f55fe213ed1a6eeafd224a907f7 Mon Sep 17 00:00:00 2001 From: Fierelier Date: Thu, 18 Mar 2021 19:04:54 +0100 Subject: [PATCH] Add user-agent --- BirdyNet.ini | 3 ++- BirdyNet.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/BirdyNet.ini b/BirdyNet.ini index 0f4f79e..876b696 100644 --- a/BirdyNet.ini +++ b/BirdyNet.ini @@ -1,2 +1,3 @@ [default] -home = https://example.com \ No newline at end of file +home = https://example.com +useragent = BirdyNet/$VER ($OS) \ No newline at end of file diff --git a/BirdyNet.py b/BirdyNet.py index 2d4275d..1e13b6f 100644 --- a/BirdyNet.py +++ b/BirdyNet.py @@ -83,6 +83,7 @@ class browserWindow(QMainWindow): # additional info: "baseUrl": "" } + self.cUserAgent = config["default"]["useragent"].replace("$OS",sys.platform).replace("$VER",versionString).replace("$DIST",distro) self.cCreateElements() def cCreateElements(self): @@ -119,7 +120,7 @@ class browserWindow(QMainWindow): def cNavigate(self,event = None): try: print(prettyJson(parseUrl(self.cUrlBar.text()))) - response = downloadPage(self.cUrlBar.text()) + response = downloadPage(self.cUrlBar.text(),{"User-Agent": self.cUserAgent}) infoFetcher(response) self.cDocumentInfo = response self.cDoc.cRenderHtml(response["body"].decode("utf-8",errors="ignore"))