Skip to content

Instantly share code, notes, and snippets.

@egradman
Created August 17, 2021 00:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egradman/1d42a5a826fa6339fa1ab7af27b3309d to your computer and use it in GitHub Desktop.
Save egradman/1d42a5a826fa6339fa1ab7af27b3309d to your computer and use it in GitHub Desktop.
generate LAUSD daily_pass
# create a file named .env containing:
#username=<username>
#password=<password>
#student_id=<student_id>
#facility_id=<facility_id>
#find the facility id by inspecting the page once you've selected your school
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.expected_conditions import presence_of_element_located
import time
import base64
import datetime
import urllib
from flask import Flask, make_response
from dotenv import dotenv_values
config = dotenv_values(".env")
def get_daily_pass():
chrome_options = Options()
chrome_options.headless = True # also works
with webdriver.Chrome(options=chrome_options) as driver:
wait = WebDriverWait(driver, 10)
driver.get("https://pap.lausd.net/en-US/signin")
driver.find_element_by_xpath("//button [contains( text(), 'Parents')]").click()
wait.until(presence_of_element_located((By.ID, "idcs-signin-basic-signin-form-username")))
driver.find_element(By.ID, "idcs-signin-basic-signin-form-username").send_keys(config['username'])
driver.find_element(By.ID, "idcs-signin-basic-signin-form-password|input").send_keys(config['password'])
driver.find_element(By.ID, "idcs-signin-basic-signin-form-submit").click()
first_result = wait.until(presence_of_element_located((By.CSS_SELECTOR, ".home-header")))
driver.find_element_by_xpath("//div [contains( text(), 'Get Daily Pass')]").click()
first_result = wait.until(presence_of_element_located((By.CSS_SELECTOR, ".student-details")))
elem = driver.find_element_by_xpath(f"//div [contains( text(), 'STUDENT ID: {config['student_id']}')]").click()
wait.until(presence_of_element_located((By.ID, "facility")))
facility_id = driver.find_element(By.ID, "facility-id")
driver.execute_script(f"arguments[0].setAttribute('value','{config['facility_id']}')", facility_id)
driver.find_element_by_xpath("//div [contains( text(), 'Next')]").click()
wait.until(presence_of_element_located((By.ID, "anycovid19symptoms_0")))
driver.find_element(By.ID, "anycovid19symptoms_0").click()
driver.find_element(By.ID, "contactwithCOVID19case_0").click()
driver.find_element(By.ID, "btnProceed").click()
wait.until(presence_of_element_located((By.ID, "qrcode")))
elem = driver.find_element_by_xpath('//*[@id="qrcode"]/img')
image_data = elem.get_attribute("src")
preamble, image_data = image_data.split(",", 1)
image_data = base64.b64decode(image_data)
filename = "qrcode.png"
with open(filename, "wb") as f:
f.write(image_data)
response = make_response(image_data)
response.headers.set('Content-Type', 'image/png')
return response
def create_app():
app = Flask("daily_pass")
@app.route('/')
def daily_pass():
return get_daily_pass()
return app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment