From 36c980d94f79ab65c08317410d8b47171cf8634e Mon Sep 17 00:00:00 2001 From: Alexander Munch-Hansen Date: Sat, 6 Apr 2019 17:38:19 +0200 Subject: [PATCH] Fixing bugs --- server/nightr/strategies/cars_in_traffic.py | 5 ++++- server/nightr/strategies/just_eat.py | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 server/nightr/strategies/just_eat.py diff --git a/server/nightr/strategies/cars_in_traffic.py b/server/nightr/strategies/cars_in_traffic.py index 8cb4ea8..f30e676 100644 --- a/server/nightr/strategies/cars_in_traffic.py +++ b/server/nightr/strategies/cars_in_traffic.py @@ -19,7 +19,10 @@ def cars_in_traffic(context: Context) -> Prediction: for lel in data['result']['records']: sum += lel['vehicleCount'] len += 1 - curr_avg = len / sum + if sum > 0: + curr_avg = len / sum + else: + curr_avg = 0 diff = day_avr - night_avr diff --git a/server/nightr/strategies/just_eat.py b/server/nightr/strategies/just_eat.py new file mode 100644 index 0000000..64ac646 --- /dev/null +++ b/server/nightr/strategies/just_eat.py @@ -0,0 +1,11 @@ +import requests +from bs4 import BeautifulSoup + + +def is_restaurant_open(name): + r = requests.get("https://www.just-eat.dk/area/8000-%C3%A5rhusc") + soup = BeautifulSoup(r.content, features='html5lib') + + print(soup.find('div', {'data-test-id': 'listingGroupOpen'})) + +is_restaurant_open("stop2shop") \ No newline at end of file