This commit is contained in:
AB
2018-04-30 02:39:48 +03:00
parent 974e6fe711
commit 5478ba03ad
3 changed files with 131 additions and 9 deletions

50
main.py
View File

@ -13,6 +13,7 @@ class Main:
self.username = username
self.SessionId = ''
self.name = ''
self.subjects = {}
def auth(self):
r = requests.get(settings.fesmu_root_url)
@ -25,7 +26,7 @@ class Main:
r = requests.post(
settings.fesmu_root_url,
data=settings.merge(
settings.scam_data, {
settings.scam_data_1, {
'ctl00$MainContent$TextBox1': self.username,
'ctl00$MainContent$TextBox2': self.password,
}),
@ -44,5 +45,48 @@ class Main:
r = requests.get(
settings.fesmu_root_url + 'studtst1.aspx',
cookies={'ASP.NET_SessionId': self.SessionId})
for tag in soup.find_all(re.compile("ctl00_MainContent_ASPxCallbackPanel1_ASPxListBox2_LBI\dT0")):
print(tag.name)
soup = BeautifulSoup(r.text, "html.parser")
# parse subjects
for subject in soup.find_all(class_="dxeListBoxItem_Aqua dxeFTM"):
if subject.get_text() != '\xa0':
self.subjects.update({subject.get_text(): []})
logging.info('Found subject %s', subject.get_text())
logging.info('Found %s subjects', len(self.subjects))
# parse tests per subject
i = 0
for subject in self.subjects:
r = requests.post(
settings.fesmu_root_url + 'studtst1.aspx',
data=settings.merge(settings.scam_data_2,
{'ctl00$MainContent$hfPred': i}),
cookies={'ASP.NET_SessionId': self.SessionId})
soup = BeautifulSoup(r.text, "html.parser")
for test in soup.find_all(class_="dxeListBoxItem_Aqua dxeLTM"):
if test.get_text() != '\xa0':
self.subjects[subject].append(test.get_text())
logging.info('%s - Found test %s' % (subject,
test.get_text()))
i += 1
#print(self.subjects)
def start_test(self, pred, test):
# start test
r = requests.post(
settings.fesmu_root_url + 'studtst1.aspx',
data=settings.merge(
settings.scam_data_3, {
'ctl00$MainContent$hfPred': pred,
'ctl00$MainContent$hfTest': test
}),
cookies={'ASP.NET_SessionId': self.SessionId})
# get test content
r = requests.get(
settings.fesmu_root_url + 'studtst2.aspx',
cookies={'ASP.NET_SessionId': self.SessionId})
soup = BeautifulSoup(r.text, "html.parser")
_a = soup.find(class_='btntest')
q=[]
for i in _a.find_all(id=re.compile("ctl00_MainContent_ASPxButton.*_B")):
q.append(i)
return(len(q))