mirror of
https://github.com/house-of-vanity/fesmoo_perdoliq.git
synced 2025-08-21 16:17:15 +00:00
Now this shit can complete any test with 100%
This commit is contained in:
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"python.pythonPath": "C:\\Users\\ab\\AppData\\Local\\Programs\\Python\\Python36-32\\python.exe",
|
"python.pythonPath": "C:\\Users\\ab\\AppData\\Local\\Programs\\Python\\Python36-32\\python.exe",
|
||||||
"python.formatting.provider": "yapf"
|
"python.formatting.provider": "yapf",
|
||||||
|
"python.linting.pylintEnabled": false
|
||||||
}
|
}
|
13
__app__.py
13
__app__.py
@@ -1,6 +1,5 @@
|
|||||||
from main import Main
|
from main import Main
|
||||||
|
|
||||||
|
|
||||||
username = '4016014'
|
username = '4016014'
|
||||||
password = '40201'
|
password = '40201'
|
||||||
|
|
||||||
@@ -8,4 +7,14 @@ app = Main(username, password)
|
|||||||
|
|
||||||
app.auth()
|
app.auth()
|
||||||
app.get_tests()
|
app.get_tests()
|
||||||
print(app.start_test(3,0))
|
#print(app.start_test(3, 0))
|
||||||
|
|
||||||
|
while True:
|
||||||
|
q = input('Subj >>> ')
|
||||||
|
a = input('Test >>> ')
|
||||||
|
app.resolve(int(q),int(a))
|
||||||
|
#q = input('Q >>> ')
|
||||||
|
#a = input('A >>> ')
|
||||||
|
#z = [a]
|
||||||
|
#app.answer(q, z)
|
||||||
|
|
||||||
|
128
main.py
128
main.py
@@ -50,7 +50,7 @@ class Main:
|
|||||||
for subject in soup.find_all(class_="dxeListBoxItem_Aqua dxeFTM"):
|
for subject in soup.find_all(class_="dxeListBoxItem_Aqua dxeFTM"):
|
||||||
if subject.get_text() != '\xa0':
|
if subject.get_text() != '\xa0':
|
||||||
self.subjects.update({subject.get_text(): []})
|
self.subjects.update({subject.get_text(): []})
|
||||||
logging.info('Found subject %s', subject.get_text())
|
logging.debug('Found subject %s', subject.get_text())
|
||||||
logging.info('Found %s subjects', len(self.subjects))
|
logging.info('Found %s subjects', len(self.subjects))
|
||||||
# parse tests per subject
|
# parse tests per subject
|
||||||
i = 0
|
i = 0
|
||||||
@@ -64,7 +64,7 @@ class Main:
|
|||||||
for test in soup.find_all(class_="dxeListBoxItem_Aqua dxeLTM"):
|
for test in soup.find_all(class_="dxeListBoxItem_Aqua dxeLTM"):
|
||||||
if test.get_text() != '\xa0':
|
if test.get_text() != '\xa0':
|
||||||
self.subjects[subject].append(test.get_text())
|
self.subjects[subject].append(test.get_text())
|
||||||
logging.info('%s - Found test %s' % (subject,
|
logging.debug('%s - Found test %s' % (subject,
|
||||||
test.get_text()))
|
test.get_text()))
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
@@ -74,8 +74,7 @@ class Main:
|
|||||||
# start test
|
# start test
|
||||||
r = requests.post(
|
r = requests.post(
|
||||||
settings.fesmu_root_url + 'studtst1.aspx',
|
settings.fesmu_root_url + 'studtst1.aspx',
|
||||||
data=settings.merge(
|
data=settings.merge(settings.scam_data_3, {
|
||||||
settings.scam_data_3, {
|
|
||||||
'ctl00$MainContent$hfPred': pred,
|
'ctl00$MainContent$hfPred': pred,
|
||||||
'ctl00$MainContent$hfTest': test
|
'ctl00$MainContent$hfTest': test
|
||||||
}),
|
}),
|
||||||
@@ -87,6 +86,125 @@ class Main:
|
|||||||
soup = BeautifulSoup(r.text, "html.parser")
|
soup = BeautifulSoup(r.text, "html.parser")
|
||||||
_a = soup.find(class_='btntest')
|
_a = soup.find(class_='btntest')
|
||||||
q = []
|
q = []
|
||||||
for i in _a.find_all(id=re.compile("ctl00_MainContent_ASPxButton.*_B")):
|
for i in _a.find_all(
|
||||||
|
id=re.compile("ctl00_MainContent_ASPxButton.*_B")):
|
||||||
q.append(i)
|
q.append(i)
|
||||||
|
logging.info("Started subj %s, test %s" % (pred, test))
|
||||||
return (len(q))
|
return (len(q))
|
||||||
|
|
||||||
|
# predict answers for any question
|
||||||
|
def predict(self, q_number):
|
||||||
|
# select question. just load its page.
|
||||||
|
answers = []
|
||||||
|
|
||||||
|
def parse(html):
|
||||||
|
a = []
|
||||||
|
soup = BeautifulSoup(html, "html.parser")
|
||||||
|
# find all correct answer
|
||||||
|
for i in soup.find_all(
|
||||||
|
'span',
|
||||||
|
attrs=
|
||||||
|
{
|
||||||
|
'style':
|
||||||
|
'display:inline-block;background-color:'\
|
||||||
|
'Aquamarine;font-size:Medium;width:860px;'
|
||||||
|
}):
|
||||||
|
logging.debug(
|
||||||
|
'Predicting answer for question #%s - %s | Answer number - %s'
|
||||||
|
% (q_number, i.text, i.get('id')[-1:]))
|
||||||
|
a.append(int(i.get('id')[-1:]))
|
||||||
|
return a
|
||||||
|
|
||||||
|
requests.post(
|
||||||
|
settings.fesmu_root_url + 'studtst2.aspx',
|
||||||
|
data=settings.merge(
|
||||||
|
settings.scam_data_4,
|
||||||
|
{'ctl00$MainContent$ASPxButton' + str(q_number): ''}),
|
||||||
|
cookies={'ASP.NET_SessionId': self.SessionId})
|
||||||
|
# send all checkboxes as answer
|
||||||
|
requests.post(
|
||||||
|
settings.fesmu_root_url + 'studtst3.aspx',
|
||||||
|
data=settings.scam_data_5,
|
||||||
|
cookies={'ASP.NET_SessionId': self.SessionId})
|
||||||
|
# get answer page
|
||||||
|
r = requests.get(
|
||||||
|
settings.fesmu_root_url + 'studtst5.aspx',
|
||||||
|
cookies={'ASP.NET_SessionId': self.SessionId},
|
||||||
|
headers={'User-Agent': 'Mozilla/1337'})
|
||||||
|
answers = parse(r.text)
|
||||||
|
if len(answers) == 0:
|
||||||
|
logging.warning(
|
||||||
|
"There isn't any correct answers for %s. Looks like"\
|
||||||
|
" something went wrong. Trying other way...", q_number
|
||||||
|
)
|
||||||
|
# send all checkboxes as answer to 30th page
|
||||||
|
requests.post(
|
||||||
|
settings.fesmu_root_url + 'studtst2.aspx',
|
||||||
|
data=settings.merge(
|
||||||
|
settings.scam_data_4,
|
||||||
|
{'ctl00$MainContent$ASPxButton' + str(q_number): ''}),
|
||||||
|
cookies={'ASP.NET_SessionId': self.SessionId})
|
||||||
|
|
||||||
|
requests.post(
|
||||||
|
settings.fesmu_root_url + 'studtst30.aspx',
|
||||||
|
data=settings.scam_data_7,
|
||||||
|
cookies={'ASP.NET_SessionId': self.SessionId})
|
||||||
|
r = requests.get(
|
||||||
|
settings.fesmu_root_url + 'studtst5.aspx',
|
||||||
|
cookies={'ASP.NET_SessionId': self.SessionId},
|
||||||
|
headers={'User-Agent': 'Mozilla/1337'})
|
||||||
|
answers = parse(r.text)
|
||||||
|
|
||||||
|
logging.info("Prediction for question %s. Answers numbers - %s" %
|
||||||
|
(q_number, answers))
|
||||||
|
return answers
|
||||||
|
|
||||||
|
def answer(self, q_number, answers):
|
||||||
|
def gen_a(a_count, answers):
|
||||||
|
a = {}
|
||||||
|
for i in range(1, a_count+1):
|
||||||
|
if i in answers:
|
||||||
|
a['ctl00$MainContent$ASPxCheckBox' + str(i)] = 'C'
|
||||||
|
a['ctl00$MainContent$hfo' + str(i)] = '1'
|
||||||
|
else:
|
||||||
|
a['ctl00$MainContent$ASPxCheckBox' + str(i)] = 'U'
|
||||||
|
a['ctl00$MainContent$hfo' + str(i)] = '0'
|
||||||
|
return a
|
||||||
|
|
||||||
|
if len(answers) == 0:
|
||||||
|
logging.warning("Incorrect answers count. Expected [1-5] got 0.")
|
||||||
|
return 1
|
||||||
|
|
||||||
|
# select question. just post to its page.
|
||||||
|
requests.post(
|
||||||
|
settings.fesmu_root_url + 'studtst2.aspx',
|
||||||
|
data=settings.merge(
|
||||||
|
settings.scam_data_4,
|
||||||
|
{'ctl00$MainContent$ASPxButton' + str(q_number): ''}),
|
||||||
|
cookies={'ASP.NET_SessionId': self.SessionId})
|
||||||
|
# mark and send correct answers
|
||||||
|
r = requests.post(
|
||||||
|
settings.fesmu_root_url + 'studtst3.aspx',
|
||||||
|
data=settings.merge(settings.scam_data_6, gen_a(5, answers)),
|
||||||
|
cookies={'ASP.NET_SessionId': self.SessionId})
|
||||||
|
|
||||||
|
if r.url == settings.fesmu_root_url + 'studtst30.aspx':
|
||||||
|
requests.post(
|
||||||
|
settings.fesmu_root_url + 'studtst2.aspx',
|
||||||
|
data=settings.merge(
|
||||||
|
settings.scam_data_4,
|
||||||
|
{'ctl00$MainContent$ASPxButton' + str(q_number): ''}),
|
||||||
|
cookies={'ASP.NET_SessionId': self.SessionId})
|
||||||
|
r = requests.post(
|
||||||
|
settings.fesmu_root_url + 'studtst30.aspx',
|
||||||
|
data=settings.merge(settings.scam_data_8, gen_a(4, answers)),
|
||||||
|
cookies={'ASP.NET_SessionId': self.SessionId})
|
||||||
|
|
||||||
|
logging.info("Send correct answer for %s. It's %s" % (q_number,
|
||||||
|
answers))
|
||||||
|
|
||||||
|
def resolve(self, subj, test):
|
||||||
|
q_count = self.start_test(subj, test)
|
||||||
|
for i in range(1, q_count + 1):
|
||||||
|
prediction = self.predict(i)
|
||||||
|
self.answer(i, prediction)
|
135
settings.py
135
settings.py
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user