-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart.py
More file actions
32 lines (22 loc) · 950 Bytes
/
start.py
File metadata and controls
32 lines (22 loc) · 950 Bytes
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
import requests
from bs4 import BeautifulSoup
from db import DBConnector
STUDENTLISTFILE: str = "config/students"
db = DBConnector()
def fill_students_db():
for student in open(STUDENTLISTFILE, 'r', encoding='utf8').read().splitlines():
name = ' '.join(student.split()[:-1])
group = student.split()[-1]
if db.aggregate_one('students', {'name': name, 'group': group}) is None:
db.add_one('students', {'name': name, 'group': group})
def update_homeworks():
resp = requests.get('http://www.kgeorgiy.info/git/geo/prog-intro-2020/src/branch/master/README.md',
verify=False).text
soup = BeautifulSoup(resp, features='html.parser')
for h2 in soup.find_all('h2'):
hw = h2.text
if db.aggregate_one('homeworks', {'name': hw}) is None:
db.add_one('homeworks', {'name': hw})
if __name__ == "__main__":
fill_students_db()
update_homeworks()