-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
15 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,43 +11,37 @@ | |
import os | ||
import requests | ||
import time | ||
from datetime import datetime, timezone, timedelta | ||
|
||
from selenium.webdriver import Firefox | ||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.support.wait import WebDriverWait | ||
from selenium.webdriver.support import expected_conditions as EC | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
|
||
# TODO: receive form data as input | ||
""" | ||
Example | ||
------- | ||
Rafael | ||
Rodrigues Ghossi | ||
[email protected] | ||
Natália | ||
Turrioni Tavares | ||
[email protected] | ||
""" | ||
default_headers = { | ||
"Accept": "application/json, text/plain, */*", | ||
"Accept-Language": "en-CA,en-US;q=0.9,en;q=0.8", | ||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Safari/605.1.15", | ||
"X-App-Version": "3ebc5f89d9acbddc41f8e8bca8bea1ded750d32e", | ||
} | ||
|
||
|
||
class BCParksReservation: | ||
def watch(self, date): | ||
while not self.check(date): | ||
time.sleep(2) | ||
os.system('say "Passes are available!"') | ||
self.reserve(date) | ||
while True: | ||
while not self.check(date): | ||
time.sleep(10) | ||
os.system('say "Passes are available!"') | ||
# self.reserve(date) | ||
|
||
def check(self, date): | ||
date = dateparser.parse(date).strftime("%Y-%m-%d") | ||
base_url = "jd7n1axqh0.execute-api.ca-central-1.amazonaws.com/api" | ||
park_params = "reservation?facility=Joffre%20Lakes&park=0363" | ||
response = requests.get(f"https://{base_url}/{park_params}") | ||
response = requests.get( | ||
f"https://{base_url}/{park_params}", headers=default_headers | ||
) | ||
response = json.loads(response.text) | ||
logging.debug(response) | ||
print(response) | ||
|
||
capacity = response[date]["DAY"]["capacity"] | ||
if capacity == "Full": | ||
|