diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-11-22 21:18:45 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-11-22 21:18:45 +0100 |
commit | 58610dc0f96e41daebb58f1d8bfff2c8a48b9ea3 (patch) | |
tree | 88978e2d930c5f36a7c1a7776f2896471e15a987 /shared.py | |
parent | f91c0e78f30676dda2503da45ab325167b1d70a0 (diff) |
autoplanner sort of working
Diffstat (limited to 'shared.py')
-rw-r--r-- | shared.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/shared.py b/shared.py new file mode 100644 index 0000000..cd14a33 --- /dev/null +++ b/shared.py @@ -0,0 +1,17 @@ +#!/bin/python3 +import urllib.request +import re +from uuid import uuid4 +from bs4 import BeautifulSoup + +def get_public_key(): + data = urllib.request.urlopen("https://www.ns.nl/reisplanner").read() + soup = BeautifulSoup(data, features="lxml") + data = "\n".join(map(lambda x: x.text, soup.select('script:-soup-contains("mlabProductKey")'))) + return re.search(r'mlabProductKey: "([0-9a-f]{32})"', data).group(1) + +def read_file(filename): + f = open(filename, "r") + r = str(f.read()) + f.close() + return r |