has added many chains
This commit is contained in:
29
rami_levi.py
29
rami_levi.py
@@ -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
|
||||
|
Reference in New Issue
Block a user