blob: 1bd86898de4f52eeeb1faf6a53c6a2c80f896896 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#!/usr/bin/env python3
import os
import re
import sys
pattern = r'<a[^>]*class=[\'"][^\'"]*evcal_evdata_row evo_clik_row[^\'"]*[\'"][^>]*href=[\'"]([^\'"]+)[\'"][^>]*>'
for slug in sys.argv[1:]:
page_path = os.path.join("events", slug, "page.html")
event_url_path = os.path.join("events", slug, "event-url")
if os.path.exists(event_url_path):
continue
with open(page_path, "r") as f:
page_content = f.read()
match = re.search(pattern, page_content)
if not match:
print(f"event {slug} has no event url")
continue
event_page_url = match.group(1)
with open(event_url_path, "w") as f:
f.write(event_page_url)
|