Compare commits
No commits in common. "e1ff78118daafbd732adc34ba7d7020f0de348e8" and "9f2ae77d2ab864f2851a487cefe89c66015384e6" have entirely different histories.
e1ff78118d
...
9f2ae77d2a
2 changed files with 12 additions and 26 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,6 +1,5 @@
|
|||
/facebook/token
|
||||
/washinsa/washinsa_data.json
|
||||
/washinsa/tripode_b_data.json
|
||||
/facebook/facebook_data.json
|
||||
/dashboard/dashboard_data.json
|
||||
/menu/menu_data.json
|
||||
|
|
|
|||
|
|
@ -21,9 +21,8 @@ Each machine row is composed of 6 columns
|
|||
- 6 - End time (The end time in format HH:MM or empty)
|
||||
'''
|
||||
|
||||
DUMP_FILE_INSA = "washinsa_data.json"
|
||||
DUMP_FILE_TRIPODE_B = "tripode_b_data.json"
|
||||
WASHINSA_URL = "https://www.proxiwash.com/weblaverie/component/weblaverie/?view=instancesfiche&format=raw&s="
|
||||
DUMP_FILE = "washinsa_data.json"
|
||||
WASHINSA_URL = "https://www.proxiwash.com/weblaverie/component/weblaverie/?view=instancesfiche&format=raw&s=cf4f39"
|
||||
DRYER_STRING = "SECHE LINGE"
|
||||
|
||||
|
||||
|
|
@ -49,22 +48,15 @@ STATE_CONVERSION_TABLE = {
|
|||
TIME_RE = re.compile("^\d\d:\d\d$")
|
||||
|
||||
|
||||
def get_json(code):
|
||||
soup = BeautifulSoup(download_page(code), 'html.parser')
|
||||
rows = get_rows(soup)
|
||||
return get_parsed_data(rows)
|
||||
|
||||
|
||||
def download_page(code):
|
||||
def download_page():
|
||||
"""
|
||||
Downloads the page from proxiwash website
|
||||
"""
|
||||
url = WASHINSA_URL + code
|
||||
try:
|
||||
with urllib.request.urlopen(url) as response:
|
||||
with urllib.request.urlopen(WASHINSA_URL) as response:
|
||||
return response.read().decode()
|
||||
except:
|
||||
print("Error processing following url: " + url)
|
||||
print("Error processing following url: " + WASHINSA_URL)
|
||||
return ""
|
||||
|
||||
|
||||
|
|
@ -86,13 +78,6 @@ def is_machine_dryer(row):
|
|||
return DRYER_STRING in row.contents[0].text
|
||||
|
||||
|
||||
def get_machine_weight(row):
|
||||
"""
|
||||
Find the maximum weight supported by the machine.
|
||||
"""
|
||||
return int(re.search("LINGE (.*?) KG", row.contents[0].text).group(1))
|
||||
|
||||
|
||||
def get_machine_number(row):
|
||||
"""
|
||||
Gets the current machine number.
|
||||
|
|
@ -192,7 +177,6 @@ def get_parsed_data(rows):
|
|||
machine = {
|
||||
"number": get_machine_number(row),
|
||||
"state": state.value,
|
||||
"maxWeight ": get_machine_weight(row),
|
||||
"startTime": "",
|
||||
"endTime": "",
|
||||
"donePercent": "",
|
||||
|
|
@ -222,10 +206,13 @@ def get_parsed_data(rows):
|
|||
|
||||
|
||||
def main():
|
||||
with open(DUMP_FILE_INSA, 'w') as f:
|
||||
json.dump(get_json("cf4f39"), f)
|
||||
with open(DUMP_FILE_TRIPODE_B, 'w') as f:
|
||||
json.dump(get_json("b310b7"), f)
|
||||
soup = BeautifulSoup(download_page(), 'html.parser')
|
||||
rows = get_rows(soup)
|
||||
with open(DUMP_FILE, 'w') as f:
|
||||
json.dump(get_parsed_data(rows), f)
|
||||
|
||||
|
||||
main()
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue