Requires: firefox-gecko
from apt, and pushover
, selenium
, and bs4
from pip.
You will need to fill in your own pushover api details.
import time, re | |
from bs4 import BeautifulSoup | |
from selenium import webdriver | |
from pushover import init, Client | |
public = Client("gzvd93ueixpk2u1rdej65pxpouui3j", api_token="a88er3ut9n3g77fw9hd45otp8jyfx2") | |
def createHeadlessFirefoxBrowser(): | |
options = webdriver.FirefoxOptions() | |
options.add_argument('--headless') | |
return webdriver.Firefox(options=options) | |
driver = createHeadlessFirefoxBrowser() | |
print("Browser ready, starting") | |
url = "https://www.turbovax.info" | |
while True: | |
print("Starting extraction.") | |
driver.get(url) | |
time.sleep(1) | |
print("Extracted.") | |
html = driver.page_source | |
page=BeautifulSoup(html,'html.parser') | |
print(page.select('div.MuiPaper-root.MuiCard-root.MuiPaper-outlined.MuiPaper-rounded')) | |
cards=page.select('div.MuiGrid-root.MuiGrid-container.MuiGrid-spacing-xs-1') | |
print(str(len(cards))+" appointments. ") | |
for card in cards: | |
location=card.find('h3').text | |
url=card.find('a', href = re.compile(r'[/]([a-z]|[A-Z])\w+')).attrs['href'] | |
tags=card.find_all(class_="MuiChip-root") | |
desc="| " | |
for tag in tags: | |
desc+=tag.text+" | " | |
times=card.find_all(class_="MuiTypography-body1") | |
for appttime in times: | |
desc+="\n"+appttime.text | |
public.send_message(desc, title="Vaccine appt. found: "+location, url=url, url_title="Book") | |
print("▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓") | |
time.sleep(5) |