Skip to content

Instantly share code, notes, and snippets.

@Kinetic27
Created July 1, 2020 11:47
Show Gist options
  • Save Kinetic27/df5770dfd8e79211b94d9f935015883e to your computer and use it in GitHub Desktop.
Save Kinetic27/df5770dfd8e79211b94d9f935015883e to your computer and use it in GitHub Desktop.
Heroku에 올리려고 짜둔 CoronaSchoolForm.py
import os
import time
from apscheduler.schedulers.blocking import BlockingScheduler
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
opts = Options()
opts.binary_location = os.environ.get("GOOGLE_CHROME_BIN")
opts.add_argument("--headless")
opts.add_argument("--disable-dev-shm-usage")
opts.add_argument("--no-sandbox")
driver = webdriver.Chrome(executable_path=os.environ.get("CHROMEDRIVER_PATH"), options=opts)
print("Started!")
sched = BlockingScheduler({'apscheduler.timezone': 'Asia/Seoul'})
@sched.scheduled_job('cron', hour='8')
def auto_form():
driver.implicitly_wait(50)
driver.get('https://eduro.goe.go.kr/stv_cvd_co00_002.do')
id_input = driver.find_element_by_css_selector('input[id="schulNm"]')
driver.execute_script("document.getElementById('schulNm').setAttribute('value', '학교명')")
time.sleep(1)
id_input.send_keys(Keys.ENTER)
time.sleep(1)
driver.find_element_by_css_selector('input[id="pName"]').send_keys("이름")
driver.find_element_by_css_selector('input[id="frnoRidno"]').send_keys("생년월일")
driver.find_element_by_css_selector('button[id="btnConfirm"]').click()
time.sleep(1)
# 맨날 바뀌길래 뭐 체크할지 알아서 넣어서 쓰셈
driver.find_element_by_css_selector('input[id="rspns011"]').click()
driver.find_element_by_css_selector('input[id="rspns02"]').click()
driver.find_element_by_css_selector('input[id="rspns070"]').click()
driver.find_element_by_css_selector('button[id="btnConfirm"]').click()
print("제출 완료!")
time.sleep(2)
sched.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment