Skip to content

Instantly share code, notes, and snippets.

@ryanking13
Last active December 13, 2019 10:18
Show Gist options
  • Select an option

  • Save ryanking13/6412a1dd368d108d122a2790d09324fa to your computer and use it in GitHub Desktop.

Select an option

Save ryanking13/6412a1dd368d108d122a2790d09324fa to your computer and use it in GitHub Desktop.
import winsound as ws
from SRT import SRT
import time
import random
def beepsound():
freq = 2000 # range : 37 ~ 32767
dur = 1000 # ms
ws.Beep(freq, dur) # winsound.Beep(frequency, duration)
id = ""
pw = ""
korail = SRT(id, pw)
dep = "수서"
arr = "신경주"
date = "20191214"
start_time = "074000"
while True:
try:
trains = korail.search_train(dep, arr, date, start_time)
# if int(trains[0].dep_time[:2]) >= 10:
# print(trains[0].dep_time)
# time.sleep(random.random() * 4)
# continue
seat = korail.reserve(trains[0])
print("seat:", seat)
beepsound()
break
except Exception as e:
print(e)
time.sleep(random.random() * 4)
print("retrying...")
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment