-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculate.py
37 lines (27 loc) · 959 Bytes
/
calculate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import re
import getpass
from login import LoggerInner
from webutils import WebUtils
from calculator import Calculator
bs_username = "cYate"
bs_password = ""
cookiefile = "brightshadows.cookies"
baseurl = "http://www.bright-shadows.net"
challengepath = "/challenges/programming/calculate"
linkPath = challengepath + "/tryout.php"
solutionPath = challengepath + "/solution.php"
if __name__ == '__main__':
bs_password = getpass.getpass("Enter password:")
LoggerInner(bs_username, bs_password, cookiefile)
pageGetter = WebUtils(cookiefile, baseurl)
problem = pageGetter.getHTML(linkPath)
print problem
v = re.search('\"[0-9a-z+-=_*]*\"', problem)
print v.group()
calculator = Calculator(v.group())
calculator.Solve()
# print calculator.result
solutionParams = "?solution="
solpath = "%s%s%s" %(solutionPath, solutionParams, calculator.stringResult)
print solpath
print pageGetter.getHTML(solpath)