2 Commits

Author SHA1 Message Date
  docjyJ e1ff78118d Edit download_page function 3 years ago
  docjyJ c971d90595 Add Support of maxWeight 3 years ago
1 changed files with 11 additions and 2 deletions
  1. 11
    2
      washinsa/washinsa_handler.py

+ 11
- 2
washinsa/washinsa_handler.py View File

@@ -59,11 +59,12 @@ def download_page(code):
59 59
     """
60 60
     Downloads the page from proxiwash website
61 61
     """
62
+    url = WASHINSA_URL + code
62 63
     try:
63
-        with urllib.request.urlopen(WASHINSA_URL + code) as response:
64
+        with urllib.request.urlopen(url) as response:
64 65
             return response.read().decode()
65 66
     except:
66
-        print("Error processing following url: " + WASHINSA_URL)
67
+        print("Error processing following url: " + url)
67 68
         return ""
68 69
 
69 70
 
@@ -85,6 +86,13 @@ def is_machine_dryer(row):
85 86
     return DRYER_STRING in row.contents[0].text
86 87
 
87 88
 
89
+def get_machine_weight(row):
90
+    """
91
+    Find the maximum weight supported by the machine.
92
+    """
93
+    return int(re.search("LINGE (.*?) KG", row.contents[0].text).group(1))
94
+
95
+
88 96
 def get_machine_number(row):
89 97
     """
90 98
     Gets the current machine number.
@@ -184,6 +192,7 @@ def get_parsed_data(rows):
184 192
         machine = {
185 193
             "number": get_machine_number(row),
186 194
             "state": state.value,
195
+            "maxWeight ": get_machine_weight(row),
187 196
             "startTime": "",
188 197
             "endTime": "",
189 198
             "donePercent": "",

Loading…
Cancel
Save