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.
- Reads links via the Google Sheets API grid data, so it retrieves the URL embedded
behind the
linktext (rich-text hyperlink, whole-cell hyperlink, orHYPERLINK()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.
pip install -r requirements.txt
playwright install chromium- Go to the Google Cloud Console, create (or pick) a project, and enable the Google Sheets API.
- Under APIs & Services → Credentials, create an OAuth client ID of type Desktop app.
- 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.
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. |
python syllabus_parser.pyThe script prints per-row progress and a final summary of how many rows were updated vs. skipped (already filled).
- 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, andtoken.jsonare gitignored — keep them out of commits.