feat: NCNU官網公告
This commit is contained in:
parent
e16e5d678f
commit
7ee2006aa0
13
api/ncnuMain.py
Normal file
13
api/ncnuMain.py
Normal file
@ -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')]
|
||||||
12
main.py
12
main.py
@ -1,13 +1,25 @@
|
|||||||
from config import CONFIG
|
from config import CONFIG
|
||||||
from api.moodle import Moodle
|
from api.moodle import Moodle
|
||||||
|
from api.ncnuMain import NcnuMain
|
||||||
|
|
||||||
|
def space():
|
||||||
|
print("\n" + "="*20 + "\n")
|
||||||
|
|
||||||
moodle = Moodle(CONFIG['moodle']['username'], CONFIG['moodle']['password'])
|
moodle = Moodle(CONFIG['moodle']['username'], CONFIG['moodle']['password'])
|
||||||
if moodle.status:
|
if moodle.status:
|
||||||
for c in moodle.getCourses("1092"):
|
for c in moodle.getCourses("1092"):
|
||||||
print(c)
|
print(c)
|
||||||
|
space()
|
||||||
for e in moodle.getUpcomingEvents():
|
for e in moodle.getUpcomingEvents():
|
||||||
print(e)
|
print(e)
|
||||||
|
space()
|
||||||
for work in moodle.getWeekWorkInCourse('47562'):
|
for work in moodle.getWeekWorkInCourse('47562'):
|
||||||
print(work)
|
print(work)
|
||||||
|
space()
|
||||||
for anno in moodle.getAnnoInCourse('47555'):
|
for anno in moodle.getAnnoInCourse('47555'):
|
||||||
print(anno)
|
print(anno)
|
||||||
|
space()
|
||||||
|
|
||||||
|
main = NcnuMain()
|
||||||
|
for anno in main.getAnno():
|
||||||
|
print(anno)
|
||||||
Loading…
Reference in New Issue
Block a user