authenticates user at HI-PLAN
This file contains 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
import requests | |
def authenticate(username, password, fh="fhin"): | |
""" | |
'authenticates' user at hiplan-app | |
@return: session id | |
@raise LoginFailedException: if login fails | |
""" | |
url = "https://www2.primuss.de/stpl/login.php" | |
values = { | |
"user": username, | |
"pwd": password, | |
"mode": "login", | |
"fh": fh, | |
"lang": "de", | |
"submitLogin":"Anmelden" | |
} | |
response = requests.post(url, data=values, params={"FH": fh, "Lang": "de"}) | |
the_page = response.text | |
session_id_list = re.findall(r"(?:name\=\"Session\".{1,5}value\=\")([A-Za-z0-9]+)(?:\")", the_page) | |
if len(session_id_list) <= 0: | |
raise LoginFailedException("could not login") | |
return session_id_list[0] | |
class LoginFailedException(Exception): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment