Skip to content

Commit

Permalink
app: add new departments
Browse files Browse the repository at this point in the history
- Graduate School of Social Sciences
- Computer Center (custom scraper)
  • Loading branch information
furkansimsekli committed Feb 21, 2023
1 parent 8f4cf6a commit 601e2bf
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
4 changes: 3 additions & 1 deletion locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"hu-ee": "Department of Electrical and Electronics Engineering",
"hu-phys": "Physics Engineering",
"hu-abofisi": "European Union Office",
"hu-bidb": "Computer Center",
"hu-me": "Department of Mechanical Engineering",
"hu-cheng": "Chemical Engineering",
"hu-bilisim": "Institute of Informatics",
Expand Down Expand Up @@ -75,5 +76,6 @@
"hu-shmyo": "Vocational School of Health Services",
"hu-sbmy": "Vocational School of Social Sciences",
"hu-baskentosbtbmyo": "Vocational School of Technical Sciences",
"hu-secmeli": "Elective Courses Coordinator"
"hu-secmeli": "Elective Courses Coordinator",
"hu-sosyalbilimler": "Graduate School of Social Sciences"
}
4 changes: 3 additions & 1 deletion locale/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"hu-ee": "Elektrik Elektronik Mühendisliği",
"hu-phys": "Fizik Mühendisliği",
"hu-abofisi": "Avrupa Birliği Ofisi",
"hu-bidb": "Bilgi İşlem Daire Başkanlığı",
"hu-me": "Makina Mühendisliği",
"hu-cheng": "Kimya Mühendisliği",
"hu-bilisim": "Bilişim Enstitüsü",
Expand Down Expand Up @@ -75,5 +76,6 @@
"hu-shmyo": "Sağlık Hizmetleri Meslek Yüksekokulu",
"hu-sbmy": "Sosyal Bilimler Meslek Yüksekokulu",
"hu-baskentosbtbmyo": "Başkent OSB Teknik Bilimler Meslek Yüksekokulu",
"hu-secmeli": "Seçmeli Dersler Koordinatörlüğü"
"hu-secmeli": "Seçmeli Dersler Koordinatörlüğü",
"hu-sosyalbilimler": "Sosyal Bilimler Enstitüsü"
}
4 changes: 3 additions & 1 deletion src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
Phys('hu-phys', 'http://www.phys.hacettepe.edu.tr/'),
Edebiyat('hu-edebiyat', 'http://www.edebiyat.hacettepe.edu.tr/'),
ABOfisi('hu-abofisi', 'https://abofisi.hacettepe.edu.tr/'),
BIDB('hu-bidb', 'http://bidb.hacettepe.edu.tr'),
BaseDepartment('hu-me', 'http://www.me.hacettepe.edu.tr/'),
BaseDepartment('hu-cheng', 'http://www.cheng.hacettepe.edu.tr/'),
BaseDepartment('hu-bilisim', 'http://www.bilisim.hacettepe.edu.tr/'),
Expand Down Expand Up @@ -62,7 +63,8 @@
BaseDepartment('hu-shmyo', 'https://shmyo.hacettepe.edu.tr/'),
BaseDepartment('hu-sbmy', 'https://sbmy.hacettepe.edu.tr/'),
BaseDepartment('hu-baskentosbtbmyo', 'https://baskentosbtbmyo.hacettepe.edu.tr/'),
BaseDepartment('hu-secmeli', 'https://secmeli.hacettepe.edu.tr/')
BaseDepartment('hu-secmeli', 'https://secmeli.hacettepe.edu.tr/'),
BaseDepartment('hu-sosyalbilimler', 'https://sosyalbilimler.hacettepe.edu.tr/')
]


Expand Down
31 changes: 31 additions & 0 deletions src/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,34 @@ async def get_announcements(self) -> list[dict]:
new_announcements.append(announcement)

return new_announcements


class BIDB(BaseDepartment):
def __init__(self, id: str, address: str):
super().__init__(id, address)

async def get_announcements(self) -> list[dict]:
async with aiohttp.ClientSession() as session:
async with session.get(self.address) as resp:
html_text: str = await resp.text(encoding='utf-8')
soup: BeautifulSoup = BeautifulSoup(html_text, 'lxml')
data = soup.find(class_='duyurular_liste').find_all('p')[:5]
new_announcements: list[dict] = []

for p in data:
date = p.find('span', class_='tarih')

if date:
p.span.decompose()

title: str = p.text.strip()

try:
url = self._complete_url(p.find('a').get('href'))
except AttributeError:
url = None

announcement = {"title": title, "content": None, "url": url}
new_announcements.append(announcement)

return new_announcements

0 comments on commit 601e2bf

Please sign in to comment.