Skip to content

Commit

Permalink
Fetch version dynamically (Fix #3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Javex committed Oct 18, 2023
1 parent a83738d commit 92ab24d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hotprices_au/sites/coles.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def start(self):
next_data_json = json.loads(next_data_script.string)
self.api_key = next_data_json['runtimeConfig']['BFF_API_SUBSCRIPTION_KEY']
self.session.headers['ocp-apim-subscription-key'] = self.api_key
self.version = next_data_json['buildId']

def get_category(self, cat_slug):
params = {
Expand All @@ -41,7 +42,7 @@ def get_category(self, cat_slug):
product_count = 0
while True:
print(f'Page {params["page"]}')
response = self.session.get(f'https://www.coles.com.au/_next/data/20231016.01_v3.55.0/en/browse/{cat_slug}.json', params=params)
response = self.session.get(f'https://www.coles.com.au/_next/data/{self.version}/en/browse/{cat_slug}.json', params=params)
try:
response.raise_for_status()
except requests.HTTPError:
Expand Down

0 comments on commit 92ab24d

Please sign in to comment.