-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchecker.py
More file actions
37 lines (27 loc) · 886 Bytes
/
checker.py
File metadata and controls
37 lines (27 loc) · 886 Bytes
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
26
27
28
29
30
31
32
33
34
35
36
37
import requests
from bs4 import BeautifulSoup
import sys
URL = "https://housegardens.cranbrook.edu/events/photo-sessions"
TARGET_DATE = "June 7"
def check():
headers = {
"User-Agent": "Mozilla/5.0"
}
response = requests.get(URL, headers=headers, timeout=15)
response.raise_for_status()
soup = BeautifulSoup(response.text, "html.parser")
text = soup.get_text().lower()
print("Checking page...")
if TARGET_DATE.lower() in text:
print(f"{TARGET_DATE} found on page")
if "sold out" not in text:
print(f"🚨 {TARGET_DATE} might be AVAILABLE!")
# Exit with error so GitHub Actions can detect it
sys.exit(1)
else:
print(f"{TARGET_DATE} is listed but sold out")
else:
print(f"{TARGET_DATE} not found")
print("Done.")
if __name__ == "__main__":
check()