import requests

s = requests.Session()
url = 'http://35.187.250.39:8080/index.php'
filterData = ['Calculate them ', ' easy right?', 
'Solve this ', ' awww', ' hurry up!', 'Please help me ',
'I think you can solve ', ' and flag is very close!',
' get flag~~~']
postData = {'result': 0}
res = s.post(url, postData)
countReq = 0
while 'HCMUS' not in res.text:
	equations = res.text.split('<br>', 1)[1]
	equations = equations.split('<br>')
	equations = equations[:len(equations)-2]
	equations = list(filter(None, equations))
	realEquations = []
	for equation in equations:
		for data in filterData:
			equation = equation.replace(data, '')
		realEquations.append(equation)
	maxI = 0
	maxLength = 0
	for i in range(0, len(realEquations)):
		if len(realEquations[i]) > maxLength:
			maxLength = len(realEquations[i])
			maxI = i
	result = eval(realEquations[maxI])
	postData['result'] = result
	res = s.post(url, postData)
	countReq = countReq + 1
	print(countReq)
	if (countReq > 1000):
		print(res.text)
		break
print(res.text)

	