mirror of
https://github.com/house-of-vanity/fesmoo_perdoliq.git
synced 2025-08-21 16:17:15 +00:00
Improved accuracy, abiliti to override accuracy, added time delays between
answers and auto commit after resolving.
This commit is contained in:
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"python.pythonPath": "C:\\Users\\ab\\AppData\\Local\\Programs\\Python\\Python36-32\\python.exe",
|
"python.pythonPath": "/bin/python",
|
||||||
"python.formatting.provider": "yapf",
|
"python.formatting.provider": "yapf",
|
||||||
"python.linting.pylintEnabled": false
|
"python.linting.pylintEnabled": false
|
||||||
}
|
}
|
@@ -7,9 +7,7 @@ config = configparser.ConfigParser()
|
|||||||
|
|
||||||
def input_line():
|
def input_line():
|
||||||
allah = [
|
allah = [
|
||||||
'༼ つ ͠° ͟ ͟ʖ ͡° ༽つ', '(☄ฺ◣д◢)☄ฺ', '( >д<)', '(ꐦ ಠ皿ಠ )', '(;≧皿≦)',
|
'>>>'
|
||||||
'((╬●∀●)', '(; ̄Д ̄)', '(;¬_¬)', '(ꐦ°᷄д°᷅)', '(*`益´*)', '(;¬_¬)',
|
|
||||||
'(メ゚皿゚)', '( ╬◣ 益◢)', '(ఠ్ఠ ˓̭ ఠ్ఠ)'
|
|
||||||
]
|
]
|
||||||
return allah[random.randint(0, len(allah)-1)]
|
return allah[random.randint(0, len(allah)-1)]
|
||||||
|
|
||||||
@@ -77,6 +75,6 @@ Type h or help for help.
|
|||||||
''')
|
''')
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
q = input('%s >>> ' % input_line())
|
q = input('Command %s ' % input_line())
|
||||||
|
|
||||||
act(q)
|
act(q)
|
||||||
|
54
main.py
54
main.py
@@ -3,6 +3,8 @@ import settings
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
from random import randint
|
||||||
|
import time
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
@@ -133,7 +135,7 @@ class Main:
|
|||||||
headers={'User-Agent': 'Mozilla/1337'})
|
headers={'User-Agent': 'Mozilla/1337'})
|
||||||
answers = parse(r.text)
|
answers = parse(r.text)
|
||||||
if len(answers) == 0:
|
if len(answers) == 0:
|
||||||
logging.warning(
|
logging.debug(
|
||||||
"There isn't any correct answers for %s. Looks like"\
|
"There isn't any correct answers for %s. Looks like"\
|
||||||
" something went wrong. Trying other way...", q_number
|
" something went wrong. Trying other way...", q_number
|
||||||
)
|
)
|
||||||
@@ -162,7 +164,7 @@ class Main:
|
|||||||
def answer(self, q_number, answers):
|
def answer(self, q_number, answers):
|
||||||
def gen_a(a_count, answers):
|
def gen_a(a_count, answers):
|
||||||
a = {}
|
a = {}
|
||||||
for i in range(1, a_count+1):
|
for i in range(1, a_count + 1):
|
||||||
if i in answers:
|
if i in answers:
|
||||||
a['ctl00$MainContent$ASPxCheckBox' + str(i)] = 'C'
|
a['ctl00$MainContent$ASPxCheckBox' + str(i)] = 'C'
|
||||||
a['ctl00$MainContent$hfo' + str(i)] = '1'
|
a['ctl00$MainContent$hfo' + str(i)] = '1'
|
||||||
@@ -203,11 +205,53 @@ class Main:
|
|||||||
logging.info("Send correct answer for %s. It's %s" % (q_number,
|
logging.info("Send correct answer for %s. It's %s" % (q_number,
|
||||||
answers))
|
answers))
|
||||||
|
|
||||||
|
def finish_test(self):
|
||||||
|
requests.post(
|
||||||
|
settings.fesmu_root_url + 'studtst2.aspx',
|
||||||
|
data=settings.scam_data_9,
|
||||||
|
cookies={'ASP.NET_SessionId': self.SessionId})
|
||||||
|
requests.post(
|
||||||
|
settings.fesmu_root_url + 'studtst4.aspx',
|
||||||
|
data=settings.scam_data_10,
|
||||||
|
cookies={'ASP.NET_SessionId': self.SessionId})
|
||||||
|
|
||||||
def resolve(self, subj, test, accuracy):
|
def resolve(self, subj, test, accuracy):
|
||||||
|
accuracy = int(accuracy)
|
||||||
|
# chance to override accuracy
|
||||||
|
accuracy_new = input('Accuracy level [%s]: ' % accuracy)
|
||||||
|
if accuracy_new != '':
|
||||||
|
try:
|
||||||
|
accuracy = int(accuracy_new)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
is_delayd = input('Wait random time per question and auto commit? [y/N]: ')
|
||||||
|
if is_delayd == 'y' or is_delayd == 'Y':
|
||||||
|
is_delayd = True
|
||||||
|
else:
|
||||||
|
is_delayd = False
|
||||||
|
|
||||||
q_count = self.start_test(subj, test)
|
q_count = self.start_test(subj, test)
|
||||||
# applying accuracy here
|
|
||||||
# spoil_count = q_count - q_count * (accuracy / 100)
|
def sleep_rand():
|
||||||
q_count = int(q_count * (int(accuracy) / 100))
|
delay = randint(20, 40)
|
||||||
|
logging.info("Going to wait %s sec for this question." % delay)
|
||||||
|
time.sleep(delay)
|
||||||
|
# applying accuracy here. trying to make resulting
|
||||||
|
# accuracy no less than requested.
|
||||||
|
spoil_count = int(q_count - q_count * (accuracy / 100))
|
||||||
|
if int(spoil_count / q_count * (-100) + 100) < accuracy:
|
||||||
|
spoil_count -= 1
|
||||||
|
|
||||||
|
# skip random `spoil_count` questions.
|
||||||
|
skip_this = []
|
||||||
|
for i in range(0, spoil_count):
|
||||||
|
skip_this.append(randint(1, q_count + 1))
|
||||||
for i in range(1, q_count + 1):
|
for i in range(1, q_count + 1):
|
||||||
|
if is_delayd == True:
|
||||||
|
sleep_rand()
|
||||||
|
if i not in skip_this:
|
||||||
prediction = self.predict(i)
|
prediction = self.predict(i)
|
||||||
self.answer(i, prediction)
|
self.answer(i, prediction)
|
||||||
|
if is_delayd == True:
|
||||||
|
self.finish_test()
|
||||||
|
|
||||||
|
34
settings.py
34
settings.py
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user