Add user-agent

This commit is contained in:
Fierelier 2021-03-18 19:04:54 +01:00
parent 00386298c6
commit 78f23db211
2 changed files with 4 additions and 2 deletions

View File

@ -1,2 +1,3 @@
[default]
home = https://example.com
home = https://example.com
useragent = BirdyNet/$VER ($OS)

View File

@ -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"))