From be0fa76c3b35e3ea05f4d3ee02b946e6062d3a79 Mon Sep 17 00:00:00 2001 From: Beejay Date: Mon, 13 Dec 2021 01:00:01 +0800 Subject: [PATCH] Added a User Agent in Headers The request fails (403) in some sites that requires User Agents. Sites like https://www.virtualsmarthome.xyz requires a User Agent. Since this site is widely use to call Alexa routines via URL, adding a User Agent on the request() seems prudent. --- amazon_dash/execute.py | 1 + 1 file changed, 1 insertion(+) diff --git a/amazon_dash/execute.py b/amazon_dash/execute.py index c8369ed..ae1a4c7 100644 --- a/amazon_dash/execute.py +++ b/amazon_dash/execute.py @@ -213,6 +213,7 @@ def execute(self, root_allowed=False): if self.data.get('auth'): kwargs['auth'] = tuple(self.data['auth'].split(':', 1)) try: + kwargs['headers']['user-agent'] ='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36' resp = request(self.data.get('method', 'get').lower(), self.data['url'], verify=self.data.get('verify', True), **kwargs)