-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfizz.py
29 lines (26 loc) · 1.01 KB
/
fizz.py
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
from bs4 import BeautifulSoup
import time
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options
def rooms_available(url:str):
chrome_options = Options()
chrome_options.add_argument("--headless") # Opens the browser up in background
chrome_options.add_argument("--log-level=3")
with Chrome(options=chrome_options) as browser:
browser.get(url)
diff = 0
start = time.time()
while diff<10:
soup = BeautifulSoup(browser.page_source, 'html.parser')
applet = soup.find("div", {"class":"parameter-not-found alert alert-warning"})
end = time.time()
diff = end-start
if applet:
break
if applet:
return not bool(applet), applet.contents[0]
else:
return not bool(applet), "unoccupied"
if __name__ == "__main__":
URL = "https://www.the-fizz.com/search/?searchcriteria=BUILDING:THE_FIZZ_HAMBURG_STUDENTS;AREA:HAMBURG"
print(rooms_available(URL))