from requests import Session BASE = "http://mustard.stt.rnl.tecnico.ulisboa.pt:25051" sesh = Session() resp = sesh.get(BASE+"/") content = resp.content.decode('utf-8') for guess in range(1,1000): resp = sesh.get(BASE+"/number/"+str(guess)) content = resp.content.decode('utf-8') if "SSof" in content: break print(guess, content)