Skip to content

cu-3rd-party/syllabus-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

syllabus-parser

Reads a column of hyperlinked cells from a Google Sheet (display text link, with a syllabus URL attached), opens each syllabus page in a headless browser, finds the «Академическая нагрузка» section, and writes the number of lectures per week and seminars per week back into the sheet.

If a row has no link attached, or the «Академическая нагрузка» section (or a specific line) can't be found, it defaults to 0 lectures and 1 seminar.

How it works

  • Reads links via the Google Sheets API grid data, so it retrieves the URL embedded behind the link text (rich-text hyperlink, whole-cell hyperlink, or HYPERLINK() formula) — not just the visible text.
  • Opens each page with a headless Chromium browser (Playwright), so JavaScript-rendered syllabus pages work.
  • Writes only empty cells in the target columns, so re-runs are safe and won't overwrite values you already have.

Setup

1. Install dependencies

pip install -r requirements.txt
playwright install chromium

2. Create Google OAuth credentials

  1. Go to the Google Cloud Console, create (or pick) a project, and enable the Google Sheets API.
  2. Under APIs & Services → Credentials, create an OAuth client ID of type Desktop app.
  3. Download the JSON and save it in this folder as credentials.json.

The first time you run the script it opens a browser asking you to log in and grant access; after that a token.json is cached and no browser prompt is needed.

3. Configure .env

Copy the template and fill it in:

cp .env.example .env
Variable Required Description
GOOGLE_SHEETS_URL yes Full URL of the spreadsheet.
SHEET_NAME yes Name of the tab that holds the links.
LINK_COLUMN no (default D) Column with the hyperlinked link cells.
LECTURES_COLUMN no (default M) Column to write lectures/week into.
SEMINARS_COLUMN no (default N) Column to write seminars/week into.
HEADER_ROWS no (default 1) Number of header rows before the data.
GOOGLE_CREDENTIALS_FILE no (default credentials.json) OAuth client file.
HEADLESS no (default true) Set false to watch the browser.

Run

python syllabus_parser.py

The script prints per-row progress and a final summary of how many rows were updated vs. skipped (already filled).

Notes

  • The account you log in with must have edit access to the spreadsheet.
  • Numbers on the syllabus pages are expected to be digits (e.g. 2 лекции). If a page spells a number out, that metric falls back to its default.
  • .env, credentials.json, and token.json are gitignored — keep them out of commits.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages