Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import requests, re, time
- def cached_request_get(url):
- global cr, ct
- try:
- time.sleep(ct)
- return cr
- except:
- ct = time.time()
- cr = requests.get(url)
- ct -= time.time()
- ct = -ct
- return cached_request_get(url)
- def get_7seg_data():
- t = re.match(r'^.*?(<table .*?>\n(.*?)\n</table>).*?$', cached_request_get("https://gist.github.com/Vusys/659670770734d2117b58b29ddb32bd51").content.decode("utf-8"), flags=re.DOTALL).groups()[-1]
- sd = ""
- while True:
- try:
- d = re.match(r'.*?<td .*?>([/ 0123456789.·_|]+)</td>.*?', t, flags=re.DOTALL)
- id = d.groups()[-1]
- if re.match(r'^(// \d|)$', id, flags=re.DOTALL): pass
- else: sd += id
- t = t[d.end(1):]
- except AttributeError: break
- return sd
- def to_ascii_seven_segment(txt, ln=-1):
- try:
- n = txt[0]
- if ln == -1:
- for ln in range(3):
- to_ascii_seven_segment(txt, ln=ln)
- print()
- else:
- if n == " ": print(" ",end=" ")
- else: print(get_7seg_data()[(int(n)*9)+(ln*3):(int(n)*9)+(ln*3)+(3)].replace("·"," "), end=" ")
- to_ascii_seven_segment(txt[1:], ln=ln)
- except:
- pass
Add Comment
Please, Sign In to add comment