Skip to content

Commit

Permalink
celeray task
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan-g committed Sep 15, 2024
1 parent 8f0d812 commit 1840d49
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions say/crawler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(self, url):
except IndexError:
self.dkp = None

def get_data(self, force=False):
def get_data(self, need_id, force=False):
if self.dkp is None:
return

Expand All @@ -126,13 +126,17 @@ def get_data(self, force=False):
else:
r = request_with_cache(url)
if r.status_code != 200:
url = self.API_URL_FRESH % self.dkp
if force:
r = requests.get(url)
else:
r = request_with_cache(url)
if r.status_code != 200:
return
if r.status_code == 302 and "fresh" in r["redirect_url"]["uri"]:
print("Checking if fresh product...")
url = self.API_URL_FRESH % self.dkp
if force:
r = requests.get(url)
else:
r = request_with_cache(url)
if r.status_code != 200:
print("Could not call the digikala api", need_id )
return
print(url)

data = r.json()['data']

Expand Down
2 changes: 1 addition & 1 deletion say/models/need_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def update(self, force=False):
from say.crawler import DigikalaCrawler

if 'digikala' in self.link:
data = DigikalaCrawler(self.link).get_data(force=force)
data = DigikalaCrawler(self.link).get_data(self.id, force=force)
else:
data = Crawler(self.link).get_data(force=force)

Expand Down

0 comments on commit 1840d49

Please sign in to comment.