2018-04-30 00:42:47 +03:00
|
|
|
import requests
|
|
|
|
import settings
|
|
|
|
import logging
|
2018-04-30 01:06:17 +03:00
|
|
|
import re
|
2018-04-30 00:42:47 +03:00
|
|
|
from bs4 import BeautifulSoup
|
|
|
|
|
2018-04-30 01:06:17 +03:00
|
|
|
logging.basicConfig(level=logging.INFO)
|
2018-04-30 00:42:47 +03:00
|
|
|
|
|
|
|
|
|
|
|
class Main:
|
|
|
|
def __init__(self, username, password):
|
|
|
|
self.password = password
|
|
|
|
self.username = username
|
|
|
|
self.SessionId = ''
|
2018-04-30 01:06:17 +03:00
|
|
|
self.name = ''
|
2018-04-30 00:42:47 +03:00
|
|
|
|
|
|
|
def auth(self):
|
|
|
|
r = requests.get(settings.fesmu_root_url)
|
|
|
|
for c in r.cookies:
|
|
|
|
if c.name == 'ASP.NET_SessionId':
|
|
|
|
self.SessionId = c.value
|
|
|
|
logging.info('ASP.NET_SessionId for curtain session is %s',
|
|
|
|
c.value)
|
|
|
|
|
|
|
|
r = requests.post(
|
|
|
|
settings.fesmu_root_url,
|
|
|
|
data=settings.merge(
|
2018-04-30 01:06:17 +03:00
|
|
|
settings.scam_data, {
|
|
|
|
'ctl00$MainContent$TextBox1': self.username,
|
|
|
|
'ctl00$MainContent$TextBox2': self.password,
|
|
|
|
}),
|
2018-04-30 00:42:47 +03:00
|
|
|
cookies={'ASP.NET_SessionId': self.SessionId})
|
|
|
|
|
2018-04-30 01:06:17 +03:00
|
|
|
r = requests.get(
|
|
|
|
settings.fesmu_root_url + 'startstu.aspx',
|
|
|
|
cookies={'ASP.NET_SessionId': self.SessionId})
|
2018-04-30 00:42:47 +03:00
|
|
|
soup = BeautifulSoup(r.text, "html.parser")
|
2018-04-30 01:06:17 +03:00
|
|
|
_p = re.compile(',.*$')
|
|
|
|
self.name = _p.sub(
|
|
|
|
'', soup.find(id="ctl00_MainContent_Label1").get_text())[14:]
|
|
|
|
logging.info('Current user is %s', self.name)
|
|
|
|
|
|
|
|
def get_tests(self):
|
|
|
|
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)
|