Created
November 7, 2020 07:39
-
-
Save Victrid/b8a05e56fb0f225f61454021cb99ad45 to your computer and use it in GitHub Desktop.
Laundry availability check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python | |
import requests | |
from bs4 import BeautifulSoup | |
import re | |
import json | |
headers = { | |
# input your tokens | |
} | |
r = requests.get("https://85.altabalink.com/device/common",headers=headers) | |
soup = BeautifulSoup(r.text,'html.parser') | |
rv = soup.select("div .placeholder") | |
status = [] | |
for r in rv: | |
status1 = re.search("([0-9]+) 分钟后可用", r.text) | |
status2 = re.search("空闲", r.text) | |
if status1==None and status2==None: | |
continue | |
if status1 != None: | |
v = {} | |
v["Status"]=True | |
v["Remaining"]=int(status1.group(1)) | |
status.append(v) | |
if status2 != None: | |
v = {} | |
v["status"]=False | |
v["Remaining"]=0 | |
status.append(v) | |
for index, value in enumerate(status): | |
value["Index"]=index | |
print(json.dumps(status)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment