Skip to content

Commit

Permalink
Course Plan Fixes
Browse files Browse the repository at this point in the history
- Updated .gitignore.
- Fixed an error caused by some selective courses not having any available courses listed.
  • Loading branch information
AtaTrkgl committed Jan 14, 2025
1 parent 04403a3 commit 34c3a14
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
src/__pycache__/
.idea/
data/*
data
35 changes: 18 additions & 17 deletions src/course_plan_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,24 @@ def scrape_iteration_course_plan(self, url:str, log_prefix:str):
selective_soup = self.get_soup_from_url(f"https://obs.itu.edu.tr{cell0_a['href']}")

selective_courses = []
selective_course_table = selective_soup.find("table")

if selective_course_table is not None:
selective_course_rows = selective_course_table.find_all("tr")

# First row is just the header.
for selective_row in selective_course_rows[1:]:
selective_courses.append(selective_row.find("a").get_text().replace("\n", "").strip())

semester_program.append({selective_courses_title.replace("\n", "").strip(): selective_courses})
else:
# Because ITU changed their website, I have no fucking clue what the "selective courses like below" is
# but the new UI might have fixed that issue. I'm leaving this here just in case
# ---------------------------------------------------------------------------------------------------
# TODO: Add support for selective courses like this:
# https://www.sis.itu.edu.tr/TR/ogrenci/lisans/ders-planlari/plan/MAK/20031081.html
semester_program.append({selective_courses_title: []})
if selective_soup is not None:
selective_course_table = selective_soup.find("table")

if selective_course_table is not None:
selective_course_rows = selective_course_table.find_all("tr")

# First row is just the header.
for selective_row in selective_course_rows[1:]:
selective_courses.append(selective_row.find("a").get_text().replace("\n", "").strip())

semester_program.append({selective_courses_title.replace("\n", "").strip(): selective_courses})
else:
# Because ITU changed their website, I have no fucking clue what the "selective courses like below" is
# but the new UI might have fixed that issue. I'm leaving this here just in case
# ---------------------------------------------------------------------------------------------------
# TODO: Add support for selective courses like this:
# https://www.sis.itu.edu.tr/TR/ogrenci/lisans/ders-planlari/plan/MAK/20031081.html
semester_program.append({selective_courses_title: []})
else:
semester_program.append(course_code)

Expand Down

0 comments on commit 34c3a14

Please sign in to comment.