This repository has been archived by the owner on Feb 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathportal.py
66 lines (56 loc) · 1.92 KB
/
portal.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import requests,pickle
from bs4 import BeautifulSoup
from model import db,users
def get_session(username, password):
passw=str(password)
user =str(username)
head={'UserID': user ,'UserPassword': passw, 'pswdStatus': 'strong', 'DummyVar': ''}
url = 'http://puya.birjandut.ir/gateway/UserInterim.php'
page = requests.post(url, data=head)
s = requests.Session()
response = s.post(url, data=head)
return requests.utils.dict_from_cookiejar(s.cookies)
def grade(session):
num = requests.get('http://puya.birjandut.ir/educ/educfac/stuShowEducationalLogFromGradeList.php',cookies=session)
page = num.text
soup = BeautifulSoup(page,'html')
row = soup.find_all('tr')
##### row ok
report=[]
for r in row:
#print r.contents
soup = BeautifulSoup(str(r),'lxml')
table = soup.find_all('td')
one_row=[]
#print table
for x in table:
one_row.append(x.string)
#print "\n\n"
report.append(one_row)
return report
def save(username,md5,chat_id):
#on start!
temp = users.query.filter_by(chat_id = chat_id).first()
if temp is not None and chat_id == temp.chat_id :
temp.username= username
temp.md5=md5
db.session.commit()
if temp is None:
new_user = users(username,md5,chat_id)
db.session.add(new_user)
db.session.commit()
def startid(chat_id):
if users.query.filter_by(chat_id = chat_id).first() is None :
new_user = users('','',chat_id)
db.session.add(new_user)
db.session.commit()
def grade_HTML(report):
html=''
for row in report:
if row is not None:
for cell in row:
if cell is not None:
html = html+'\n'+cell
html = html + '\n-------------'
html = html + '\n Developed By @Cyanogen_ir \n BenYamin Salimi \n Github: BenYaminSalimi \ '
return html