-
Notifications
You must be signed in to change notification settings - Fork 7
Properly ignore first col of tables in scrape_term #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,15 +69,19 @@ def parse(content, db): | |
| rows = t.find_all('tr', {'class': 'CourseRow'}) | ||
| s = defaultdict(lambda: defaultdict(list)) | ||
| for tr in rows: | ||
| cols = tr.find_all(lambda tag: tag.name == 'td' and not tag.get_text().isspace()) | ||
| cols = tr.find_all(lambda tag: tag.name == 'td') | ||
|
|
||
| if cols: | ||
| # The first <td> is a field that is not relevant to us | ||
| # it is either empty or contains a "flag" icon | ||
| cols.pop(0) | ||
|
phi-line marked this conversation as resolved.
|
||
|
|
||
| for i, c in enumerate(cols): | ||
| a = c.find('a') | ||
| cols[i] = (a.get_text() if a else cols[i].get_text()).strip() | ||
|
|
||
| try: | ||
| key = get_key(f'{cols[0] if cols[0] else cols[1]}')[0] | ||
| key = get_key(cols[0])[0] | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh wait, not sure if this is necessary / what it breaks.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is okay now because you popped the first.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to my testing, it seems to work fine. (Tested with LiveMyPortalData) |
||
| data = dict(zip(HEADERS, cols)) | ||
|
|
||
| crn = data['CRN'] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🏳️ 🏳️ 🏳️