Skip to content

Commit a95f403

Browse files
committed
fix: Add error logging for course ID fetching and log course counts found during scraping
1 parent 123ed75 commit a95f403

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,11 @@ def get_course_id(self):
11091109
except requests.exceptions.ConnectionError:
11101110
r = None
11111111
continue
1112+
except Exception as e:
1113+
logger.error(f"Error fetching course ID: {e}")
1114+
logger.error(f"Course URL: {url}")
1115+
r = None
1116+
continue
11121117

11131118
if r is None:
11141119
logger.error("Failed to fetch course ID after 3 attempts")
@@ -1122,7 +1127,6 @@ def get_course_id(self):
11221127
course_id = soup.find("body").get("data-clp-course-id", "invalid")
11231128
if course_id == "invalid":
11241129
self.course.is_valid = False
1125-
logger.error(soup.prettify(encoding="utf-8"))
11261130
self.course.error = "Course ID not found: Report to developer"
11271131
return
11281132

cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ def create_scraping_thread(site: str):
185185
time.sleep(0.1)
186186

187187
udemy.progress.update(task_id, completed=getattr(scraper, f"{code_name}_length"))
188+
logger.debug(f"Courses Found {code_name}: {len(getattr(scraper, f'{code_name}_data'))}")
189+
188190
if getattr(scraper, f"{code_name}_error"):
189191
raise Exception(f"Error in: {site}")
190192
except Exception:

gui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def create_scraping_thread(site: str):
6666
)
6767

6868
time.sleep(0.1)
69-
69+
logger.info(f"Courses Found {code_name}: {len(getattr(scraper, f'{code_name}_data'))}")
7070
if getattr(scraper, f"{code_name}_error"):
7171
raise Exception(f"Error in: {site}")
7272
except Exception:

0 commit comments

Comments
 (0)