has added many chains

This commit is contained in:
KorenLazar
2021-02-06 21:42:31 +02:00
parent 5aa4cd734d
commit 18f3fa32b9
20 changed files with 198 additions and 73 deletions

View File

@@ -1,28 +1,11 @@
import json
import requests
from cerberus_web_client import CerberusWebClient
from supermarket_chain import SupermarketChain
class RamiLevi(SupermarketChain):
class RamiLevi(CerberusWebClient, SupermarketChain):
_date_hour_format = '%Y-%m-%d %H:%M:%S'
_class_name = 'RamiLevi'
@staticmethod
def get_download_url(store_id: int, category: SupermarketChain.XMLFilesCategory, session: requests.Session) -> str:
hostname: str = "https://publishedprices.co.il"
# Post the payload to the site to log in
session.post(hostname + "/login/user", data={'username': 'ramilevi'})
# Scrape the data
ajax_dir_payload: dict = {'iDisplayLength': 100000, 'sSearch': category.name.replace('s', '')}
s: requests.Response = session.post(hostname + "/file/ajax_dir", data=ajax_dir_payload)
s_json: dict = json.loads(s.text)
suffix: str = next(d['name'] for d in s_json['aaData'] if f'-{store_id:03d}-20' in d['name'])
download_url: str = hostname + "/file/d/" + suffix
print(download_url)
return download_url
def __repr__(self):
return 'RamiLevi'
@property
def username(self):
return self._class_name