Skip to content

Commit

Permalink
tasks bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan-g committed Dec 1, 2024
1 parent 24d88d3 commit 307d35c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions say/crawler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 307d35c

Please sign in to comment.