From acfdcf97a03106d3d58e5c4b44e8095cae2f6ab8 Mon Sep 17 00:00:00 2001 From: rafapolo Date: Thu, 27 Aug 2026 09:28:58 +0200 Subject: [PATCH] feat: include posting links in sciCORE watch alerts Keep each vacancy's href when flattening the listing HTML, resolved to an absolute URL, so the Telegram alert links straight to the application page instead of the listing index. The extractor runs as python3 -c inside shell single quotes, so the anchor pattern's quote class is built with chr(39) rather than written inline. --- scripts/scicore-watch.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/scripts/scicore-watch.sh b/scripts/scicore-watch.sh index 867c61e..c32c2e3 100755 --- a/scripts/scicore-watch.sh +++ b/scripts/scicore-watch.sh @@ -51,13 +51,27 @@ $URL" fi echo 0 > "$FAILS" -CURRENT=$(printf '%s' "$HTML" | python3 -c ' -import sys, re, html +CURRENT=$(printf '%s' "$HTML" | SCICORE_BASE="$URL" python3 -c ' +import sys, re, html, os +from urllib.parse import urljoin +BASE = os.environ.get("SCICORE_BASE", "") h = sys.stdin.read() m = re.search(r"

Join the team!

(.*?)", "", body, flags=re.S | re.I) body = re.sub(r"]*>", "\n- ", body, flags=re.I) + +# Keep the posting URL: Role -> "Role -> X", so the alert can be +# tapped straight through to the application page instead of the listing index. +QUOTES = chr(34) + chr(39) +A_TAG = "]*href=([" + QUOTES + "])(.*?)\\1[^>]*>(.*?)" +def keep_link(m): + href = html.unescape(m.group(2)).strip() + text = re.sub(r"<[^>]+>", "", m.group(3)).strip() + if not href or href.startswith(("#", "mailto:", "javascript:")): + return text + return "{} -> {}".format(text, urljoin(BASE, href)) +body = re.sub(A_TAG, keep_link, body, flags=re.S | re.I) body = re.sub(r"", "\n", body, flags=re.I) body = re.sub(r"<[^>]+>", " ", body) body = html.unescape(body)