diff --git a/api/ncnuMain.py b/api/ncnuMain.py new file mode 100644 index 0000000..7b1ea10 --- /dev/null +++ b/api/ncnuMain.py @@ -0,0 +1,13 @@ +from api.tools import * +import requests +from bs4 import BeautifulSoup + +class NcnuMain(): + def getAnno(self): + response = requests.get('https://www.ncnu.edu.tw/ncnuweb/ann/tabs.aspx?homeType=ncnu&unit=ncnu') + block = find(response, 'div', param={'id': 'annNews'}) + + return [{ + 'title': " ".join(anno.text.split(' ')[1:]), + 'link': "https://www.ncnu.edu.tw/ncnuweb/ann/" + anno.get('href') + } for anno in block.findAll('a')] diff --git a/main.py b/main.py index c16ca88..032923f 100644 --- a/main.py +++ b/main.py @@ -1,13 +1,25 @@ from config import CONFIG from api.moodle import Moodle +from api.ncnuMain import NcnuMain + +def space(): + print("\n" + "="*20 + "\n") moodle = Moodle(CONFIG['moodle']['username'], CONFIG['moodle']['password']) if moodle.status: for c in moodle.getCourses("1092"): print(c) + space() for e in moodle.getUpcomingEvents(): - print(e) + print(e) + space() for work in moodle.getWeekWorkInCourse('47562'): print(work) + space() for anno in moodle.getAnnoInCourse('47555'): - print(anno) \ No newline at end of file + print(anno) + space() + +main = NcnuMain() +for anno in main.getAnno(): + print(anno) \ No newline at end of file