from requests import get import re BASE = "http://mustard.stt.rnl.tecnico.ulisboa.pt:25053" resp = get(BASE+"/hello") content = resp.content.decode('utf-8') target = re.search(r"target ([0-9]+)", content).group(1) print("Target:", target) current = 0 while current != target: resp = get(BASE+"/more", cookies=resp.cookies) content = resp.content.decode('utf-8') current = re.search(r"current value is: ([0-9]+)", content).group(1) print("Current:", current) resp = get(BASE+"/finish", cookies=resp.cookies) print(resp.content)