class MetMast(): def __init__(self): pass def getTemperature(self): return self.__getValue('OutsideTemperature') def getInsolation(self): return self.__getValue('Insolation') def getWindDirection(self): return self.__getValue('WindDirection') def getWindSpeed(self): return self.__getValue('WindSpeed') def __getValue(self, key): from requests import get, auth import re if not type(key) is str: raise TypeError('Key should be a string, found {0}'.format(type(key))) assert key is not '', 'Key should not be an empty string' url = 'http://whiteboard.syslab.dk/wbget.php' r = get(url, auth=auth.HTTPBasicAuth('twinPV99', 'twinPV99')) entries = r.text.split('\n') result = None for entry in entries: entry = entry.rstrip().lstrip() g = re.match('SYSLAB@(\d+):{0}=(.+);'.format(key), entry) if g is None: continue else: g = g.groups() result = g[1] break return result