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
|
/facebook/token
|
||||||
/washinsa/washinsa_data.json
|
/washinsa/washinsa_data.json
|
||||||
/washinsa/tripode_b_data.json
|
|
||||||
/facebook/facebook_data.json
|
/facebook/facebook_data.json
|
||||||
/dashboard/dashboard_data.json
|
/dashboard/dashboard_data.json
|
||||||
/menu/menu_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)
|
- 6 - End time (The end time in format HH:MM or empty)
|
||||||
'''
|
'''
|
||||||
|
|
||||||
DUMP_FILE_INSA = "washinsa_data.json"
|
DUMP_FILE = "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=cf4f39"
|
||||||
WASHINSA_URL = "https://www.proxiwash.com/weblaverie/component/weblaverie/?view=instancesfiche&format=raw&s="
|
|
||||||
DRYER_STRING = "SECHE LINGE"
|
DRYER_STRING = "SECHE LINGE"
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -49,22 +48,15 @@ STATE_CONVERSION_TABLE = {
|
||||||
TIME_RE = re.compile("^\d\d:\d\d$")
|
TIME_RE = re.compile("^\d\d:\d\d$")
|
||||||
|
|
||||||
|
|
||||||
def get_json(code):
|
def download_page():
|
||||||
soup = BeautifulSoup(download_page(code), 'html.parser')
|
|
||||||
rows = get_rows(soup)
|
|
||||||
return get_parsed_data(rows)
|
|
||||||
|
|
||||||
|
|
||||||
def download_page(code):
|
|
||||||
"""
|
"""
|
||||||
Downloads the page from proxiwash website
|
Downloads the page from proxiwash website
|
||||||
"""
|
"""
|
||||||
url = WASHINSA_URL + code
|
|
||||||
try:
|
try:
|
||||||
with urllib.request.urlopen(url) as response:
|
with urllib.request.urlopen(WASHINSA_URL) as response:
|
||||||
return response.read().decode()
|
return response.read().decode()
|
||||||
except:
|
except:
|
||||||
print("Error processing following url: " + url)
|
print("Error processing following url: " + WASHINSA_URL)
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -86,13 +78,6 @@ def is_machine_dryer(row):
|
||||||
return DRYER_STRING in row.contents[0].text
|
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):
|
def get_machine_number(row):
|
||||||
"""
|
"""
|
||||||
Gets the current machine number.
|
Gets the current machine number.
|
||||||
|
|
@ -192,7 +177,6 @@ def get_parsed_data(rows):
|
||||||
machine = {
|
machine = {
|
||||||
"number": get_machine_number(row),
|
"number": get_machine_number(row),
|
||||||
"state": state.value,
|
"state": state.value,
|
||||||
"maxWeight ": get_machine_weight(row),
|
|
||||||
"startTime": "",
|
"startTime": "",
|
||||||
"endTime": "",
|
"endTime": "",
|
||||||
"donePercent": "",
|
"donePercent": "",
|
||||||
|
|
@ -222,10 +206,13 @@ def get_parsed_data(rows):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
with open(DUMP_FILE_INSA, 'w') as f:
|
soup = BeautifulSoup(download_page(), 'html.parser')
|
||||||
json.dump(get_json("cf4f39"), f)
|
rows = get_rows(soup)
|
||||||
with open(DUMP_FILE_TRIPODE_B, 'w') as f:
|
with open(DUMP_FILE, 'w') as f:
|
||||||
json.dump(get_json("b310b7"), f)
|
json.dump(get_parsed_data(rows), f)
|
||||||
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue