Skip to content

Instantly share code, notes, and snippets.

Last active December 17, 2015 01:10
What would you like to do?
authenticates user at HI-PLAN
import requests
def authenticate(username, password, fh="fhin"):
'authenticates' user at hiplan-app
@return: session id
@raise LoginFailedException: if login fails
url = ""
values = {
"user": username,
"pwd": password,
"mode": "login",
"fh": fh,
"lang": "de",
response =, 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):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment