From: Oleg Broytman Date: Sun, 18 Aug 2024 19:57:57 +0000 (+0300) Subject: Refactor(Robots/base): Simplify `X-User-Agent` X-Git-Tag: 6.0.0~4 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=409fe6828321bfb9f337758e347603227085afec;p=bookmarks_db.git Refactor(Robots/base): Simplify `X-User-Agent` --- diff --git a/Robots/base.py b/Robots/base.py index a504e47..c63504b 100644 --- a/Robots/base.py +++ b/Robots/base.py @@ -35,7 +35,7 @@ request_headers = { 'Referer': '/', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:120.0) ' 'Gecko/20100101 Firefox/120.0', - 'X-User-Agent': 'bookmarks_db %s (Python %d.%d.%d)' % ( + 'X-User-Agent': 'bookmarks_db %s (Python %d.%d.%d) ' % ( __version__, *sys.version_info[:3]), } @@ -87,9 +87,7 @@ class robot_base(Robot): setattr(self, attr, value) Robot.__init__(self, *args, **kw) socket.setdefaulttimeout(self.timeout) - - request_headers['X-User-Agent'] = '%s %s' % ( - request_headers['X-User-Agent'], self.version_str()) + request_headers['X-User-Agent'] += self.version_str() def version_str(self): return self.__class__.__name__