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 c9285b3 commit c108925
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions say/crawler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ def __init__(self, url):
self.dkp = None

def get_data(self, force=False):
result = None

if self.dkp is None:
return

Expand All @@ -124,10 +126,8 @@ def get_data(self, force=False):
r = requests.get(url)
else:
r = request_with_cache(url)
if r.status_code != 200:
return
result = r.json()

# 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["status"] == 302 and "fresh" in result["redirect_url"]["uri"]:
Expand All @@ -136,10 +136,11 @@ def get_data(self, force=False):
r = requests.get(url)
else:
r = request_with_cache(url)
if r.status_code != 200:
return
result = r.json()


if r.status_code != 200:
return
data = result['data']

if data['product'].get('is_inactive'):
Expand Down

0 comments on commit c108925

Please sign in to comment.