pingping.py
1 |
|
2 |
# public API. |
3 |
# Given the account number and password/passphrase, this script returns the |
4 |
# remaining budget associated with the account. |
5 |
# |
6 |
# This is a proof of concept; it's extremely barebones and doesn't include tests |
7 |
# or anything. Requires Python 3 and the Requests library in order to work. |
8 |
import requests |
9 |
|
10 |
link = "https://uhasselt-pxl.mynetpay.be/Account/Login" |
11 |
# Get CSRF token |
12 |
first_call = requests.get(link) |
13 |
text = first_call.text |
14 |
begin = text.find('__RequestVerificationToken') |
15 |
begin = text.find('value="', begin) |
16 |
end = text.find('" ', begin) |
17 |
token = text[begin+len('value="'):end] |
18 |
cookies = first_call.cookies |
19 |
|
20 |
username = "" |
21 |
password = "" |
22 |
|
23 |
response = requests.post(link, data={ |
24 |
'Username':username, |
25 |
'LoginType':'Student', |
26 |
'Password':password, |
27 |
'__RequestVerificationToken':token, |
28 |
}, cookies=cookies) |
29 |
|
30 |
html_response = response.text |
31 |
start = html_response.find(": € ") |
32 |
offset = len(": € ") |
33 |
print(html_response[start+offset:start+offset+5]) |
34 |