Commit f83fbb9a authored by IS1_4M's avatar IS1_4M
Browse files

using rss feed for T@Earlham for more dependibility

parent 02cc6b41
......@@ -16,7 +16,7 @@ from PublicChannel import PubChanSuite, PublicChan
from ClubChannel import ClubSuite, Club
from restrictedchannel import RestrictChan, RestrictChanSuite
from handles import User, ECMember, ECStudent, ECFaculty, Organizer, Convener, Admin, SuperAdmin
from test_get_mail import get_today_at_school
from rssfeedtest import get_today_at_earlham
import json
def get_member_by_discord_name(guild, discord_name):
......@@ -69,7 +69,7 @@ async def update_today_at_schools():
print('searching guild:', guild.name)
today_at_school = None
today_at_virtual_school = None
virtual_annoucements, local_annoucements = get_today_at_school(send_account_email, account_password)
virtual_annoucements, local_annoucements = get_today_at_earlham()
for channel in guild.channels:
print(channel.name)
print('\t', channel.name == 'today-at-earlham', channel.name == 'today-at-remote-earlham')
......
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 5 09:25:13 2020
@author: josep
"""
'''import feedparser
feed = feedparser.parse('https://earlham.edu/news/today/rss/')
print(feed.keys())
print(feed.entries)
print(feed['feed'])
print(feed['bozo'])
print(feed['bozo_exception'])
'''
from bs4 import BeautifulSoup
import urllib.request
import ssl
def get_today_at_earlham():
ssl._create_default_https_context = ssl._create_unverified_context
opener = urllib.request.urlopen
url = "https://earlham.edu/news/today/rss/"
html_doc = opener(url)
soup = BeautifulSoup(html_doc, 'html.parser')
items = soup.find_all('item')
virtual_announcements = []
local_announcements = []
for item in items:
announcement = '\n\t'.join(item.title.contents + item.description.contents)
announcementl = announcement.lower()
if 'virtual' in announcementl or 'zoom' in announcementl or 'remote' in announcementl or 'online' in announcementl:
virtual_announcements.append(announcement)
else:
local_announcements.append(announcement)
return virtual_announcements, local_announcements
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment