aboutsummaryrefslogtreecommitdiff
path: root/extract-id
blob: 698b6ae082a164a8fcb0fd36c2d58f4f359e7a7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env python3
import os
import re
import sys

for slug in sys.argv[1:]:
    page_path = os.path.join("events", slug, "page.html")
    page_content = open(page_path).read()
    event_id_match = re.search(
        r'href="https://www.portugalrunning.com/wp-json/wp/v2/ajde_events/(\d+)"',
        page_content,
    )
    assert event_id_match is not None, f"failed to extract event id from {slug}"
    event_id_path = os.path.join("events", slug, "id")
    with open(event_id_path, "w") as f:
        f.write(event_id_match[1].strip())