Last active
February 13, 2023 23:07
-
-
Save trbarron/b9e2bcf148c3712adf18bffe4cb655b2 to your computer and use it in GitHub Desktop.
little selenium thing to find Jack a top golf reservation
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
import time | |
from selenium import webdriver | |
from selenium.webdriver.support.ui import WebDriverWait | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.chrome.service import Service | |
from twilio.rest import Client | |
# Find your Account SID and Auth Token at twilio.com/console | |
# and set the environment variables. See http://twil.io/secure | |
# os.environ['TWILIO_ACCOUNT_SID'] | |
account_sid = "secret code 1 here" | |
# os.environ['TWILIO_AUTH_TOKEN'] | |
auth_token = "secret code 2 here" | |
client = Client(account_sid, auth_token) | |
players = [ | |
{ | |
"name": "Jack", | |
"number": phone # here | |
}, | |
{ | |
"name": "Tyler", | |
"number": other phone # here | |
} | |
] | |
def checkTennis(): | |
URL = 'https://www.sevenrooms.com/reservations/topgolfelsegundo?default_date=2023-02-16&default_party_size=6&default_time=6:00PM' | |
# initialize the Chrome driver | |
chrome_options = webdriver.ChromeOptions() | |
# chrome_options.add_argument("--headless") | |
chrome_options.add_argument("--window-size=1920,1080") | |
chrome_options.add_argument("--log-level=3") | |
chrome_options.add_experimental_option('excludeSwitches', ['enable-logging']) | |
s = Service('./chromedriver.exe') | |
# driver = webdriver.Chrome(chrome_options=chrome_options, executable_path="./chromedriver") | |
driver = webdriver.Chrome(service=s, options=chrome_options) | |
# head to github login page | |
driver.get(URL) | |
# click search button | |
driver.find_element(By.CSS_SELECTOR, ".cbwgvL").click() | |
WebDriverWait(driver=driver, timeout=10).until( | |
lambda x: x.execute_script("return document.readyState === 'complete'") | |
) | |
time.sleep(2) | |
mainResultsDisplay = driver.find_element(By.CSS_SELECTOR, ".eHqqQV") | |
print(mainResultsDisplay.text) | |
mainResultsDisplayText = mainResultsDisplay.text | |
goodTimes = ["6:", "7:", "8:", "9:", "10:"] | |
for times in goodTimes: | |
if times in mainResultsDisplayText: | |
print("AWW SHIT") | |
textPeople() | |
def textPeople(): | |
for person in players: | |
message = 'dearest ' + person['name'] + ', \n Aww shit looks like there is a time available you should check \n https://www.sevenrooms.com/reservations/topgolfelsegundo?default_date=2023-02-16&default_party_size=6&default_time=6:00PM' | |
message = client.messages \ | |
.create( | |
body=message, | |
from_='+final secret phone # here', | |
to='+' + str(person["number"]) | |
) | |
print(message.sid) | |
if __name__ == '__main__': | |
print("... here we go!...") | |
while True: | |
checkTennis() | |
time.sleep(15) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment