From 307d35c1927dcad30c8d42062914349bf6834288 Mon Sep 17 00:00:00 2001 From: ehsang Date: Sun, 1 Dec 2024 23:24:07 +0330 Subject: [PATCH] tasks bug fix --- say/crawler/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/say/crawler/__init__.py b/say/crawler/__init__.py index ee5558a7..bb83a4d5 100644 --- a/say/crawler/__init__.py +++ b/say/crawler/__init__.py @@ -127,12 +127,16 @@ def get_data(self, force=False): else: r = request_with_cache(url) - if r.status_code == 200: + if r.status == 200 or r.status == 302: result = r.json() + else: + print("Cold not update!") + return + # fresh products have different api / Digikala redirect to new link for fresh product # Typical response: {'status': 302, 'redirect_url': {'base': None, 'uri': '/fresh/product/dkp-10269403/'}} - if result and result["status"] == 302 and "fresh" in result["redirect_url"]["uri"]: + if result["status"] == 302 and "fresh" in result["redirect_url"]["uri"]: url = self.API_URL_FRESH % self.dkp if force: r = requests.get(url)