From a6b308731717c38072ecc8f6947644b64a6d491c Mon Sep 17 00:00:00 2001 From: AuroraWright Date: Fri, 16 Feb 2024 09:49:50 +0100 Subject: [PATCH] Make Lens cooperate a bit more --- owocr/ocr.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/owocr/ocr.py b/owocr/ocr.py index 58ff951..f719092 100644 --- a/owocr/ocr.py +++ b/owocr/ocr.py @@ -202,9 +202,11 @@ class GoogleLens: timestamp = int(time.time() * 1000) url = f'https://lens.google.com/v3/upload?stcs={timestamp}' + headers = {'User-Agent': 'Mozilla/5.0 (Linux; Android 13; RMX3771) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.6167.144 Mobile Safari/537.36'} + cookies = {'SOCS': 'CAESEwgDEgk0ODE3Nzk3MjQaAmVuIAEaBgiA_LyaBg'} files = {'encoded_image': ('owo' + str(timestamp) + '.png', self._preprocess(img), 'image/png')} try: - res = requests.post(url, files=files, timeout=20) + res = requests.post(url, files=files, headers=headers, cookies=cookies, timeout=20) except requests.exceptions.Timeout: return (False, 'Request timeout!') except requests.exceptions.ConnectionError: