• Stars
    star
    149
  • Rank 247,635 (Top 5 %)
  • Language
    Python
  • License
    Other
  • Created about 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Korail (www.letskorail.com) wrapper for Python.

Legal disclaimer

Usage of korail for attacking targets without prior mutual consent is illegal. It's the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program. Only use for educational purposes.


Korail2

Build Status

Korail (www.letskorail.com) wrapper for Python.

This project was inspired from korail of devxoul.

Documentation

The documentation is available at here

Installing

To install korail2, simply:

$ pip install korail2

Or, you can use:

$ easy_install korail2

Or, you can also install manually:

$ git clone git://github.com/carpedm20/korail2.git
$ cd korail2
$ python setup.py install

Using

1. Login

First, you need to create a Korail object.

>>> from korail2 import *
>>> korail = Korail("12345678", YOUR_PASSWORD) # with membership number
>>> korail = Korail("[email protected]", YOUR_PASSWORD) # with email
>>> korail = Korail("010-9964-xxxx", YOUR_PASSWORD) # with phone number

If you do not want login automatically,

>>> korail = Korail("12345678", YOUR_PASSWORD, auto_login=False)
>>> korail.login()
True

When you want change ID using existing object,

>>> korail.login(ANOTHER_ID, ANOTHER_PASSWORD)
True

2. Search train

You can search train schedules search_train and search_train_allday methods.

  • search_train returns 10 results max. Faster than search_train_allday.
  • search_train_allday returns all results after the time.
  • search_train_allday uses search_train repeatedly.

search_train and search_train_allday methods take these arguments:

  • dep : A departure station in Korean ex) '์„œ์šธ'
  • arr : A arrival station in Korean ex) '๋ถ€์‚ฐ'
  • date : (optional) A departure date in yyyyMMdd format
  • time : (optional) A departure time in hhmmss format
  • train_type: (optional) A type of train. You can use constants of TrainType class here. default value is TrainType.ALL.
    • 00: TrainType.KTX - KTX
    • 01: TrainType.SAEMAEUL - ์ƒˆ๋งˆ์„ํ˜ธ
    • 02: TrainType.MUGUNGHWA - ๋ฌด๊ถํ™”ํ˜ธ
    • 03: TrainType.TONGGEUN - ํ†ต๊ทผ์—ด์ฐจ
    • 04: TrainType.NURIRO - ๋ˆ„๋ฆฌ๋กœ
    • 05: TrainType.ALL - ์ „์ฒด
    • 06: TrainType.AIRPORT - ๊ณตํ•ญ์งํ†ต
    • 07: TrainType.KTX_SANCHEON - KTX-์‚ฐ์ฒœ
    • 08: TrainType.ITX_SAEMAEUL - ITX-์ƒˆ๋งˆ์„
    • 09: TrainType.ITX_CHEONGCHUN - ITX-์ฒญ์ถ˜
  • (optional) passengers=None : List of Passenger Objects. None means 1 AdultPassenger.
  • (optional) include_no_seats=False : When True, a result includes trains which has no seats.

Below is a sample usage of search_train:

>>> dep = '์„œ์šธ'
>>> arr = '๋™๋Œ€๊ตฌ'
>>> date = '20140815'
>>> time = '144000'
>>> trains = korail.search_train(dep, arr, date, time)
[[KTX] 8์›” 3์ผ, ์„œ์šธ~๋ถ€์‚ฐ(11:00~13:42) ํŠน์‹ค,์ผ๋ฐ˜์‹ค ์˜ˆ์•ฝ๊ฐ€๋Šฅ,
 [ITX-์ƒˆ๋งˆ์„] 8์›” 3์ผ, ์„œ์šธ~๋ถ€์‚ฐ(11:04~16:00) ์ผ๋ฐ˜์‹ค ์˜ˆ์•ฝ๊ฐ€๋Šฅ,
 [KTX] 8์›” 3์ผ, ์„œ์šธ~๋ถ€์‚ฐ(12:00~14:43) ํŠน์‹ค,์ผ๋ฐ˜์‹ค ์˜ˆ์•ฝ๊ฐ€๋Šฅ,
 [KTX] 8์›” 3์ผ, ์„œ์šธ~๋ถ€์‚ฐ(12:30~15:13) ํŠน์‹ค,์ผ๋ฐ˜์‹ค ์˜ˆ์•ฝ๊ฐ€๋Šฅ,
 [KTX] 8์›” 3์ผ, ์„œ์šธ~๋ถ€์‚ฐ(12:40~15:45) ํŠน์‹ค,์ผ๋ฐ˜์‹ค ์˜ˆ์•ฝ๊ฐ€๋Šฅ,
 [KTX] 8์›” 3์ผ, ์„œ์šธ~๋ถ€์‚ฐ(12:55~15:26) ํŠน์‹ค,์ผ๋ฐ˜์‹ค ์˜ˆ์•ฝ๊ฐ€๋Šฅ,
 [KTX] 8์›” 3์ผ, ์„œ์šธ~๋ถ€์‚ฐ(13:00~15:37) ํŠน์‹ค,์ผ๋ฐ˜์‹ค ์˜ˆ์•ฝ๊ฐ€๋Šฅ,
 [KTX] 8์›” 3์ผ, ์„œ์šธ~๋ถ€์‚ฐ(13:10~15:58) ํŠน์‹ค,์ผ๋ฐ˜์‹ค ์˜ˆ์•ฝ๊ฐ€๋Šฅ]

When you want to see sold-out trains.

>>> trains = korail.search_train(dep, arr, date, time, include_no_seats=True)
[[KTX] 8์›” 3์ผ, ์„œ์šธ~๋ถ€์‚ฐ(11:00~13:42) ํŠน์‹ค,์ผ๋ฐ˜์‹ค ์˜ˆ์•ฝ๊ฐ€๋Šฅ,
 [ITX-์ƒˆ๋งˆ์„] 8์›” 3์ผ, ์„œ์šธ~๋ถ€์‚ฐ(11:04~16:00) ์ผ๋ฐ˜์‹ค ์˜ˆ์•ฝ๊ฐ€๋Šฅ,
 [๋ฌด๊ถํ™”ํ˜ธ] 8์›” 3์ผ, ์„œ์šธ~๋ถ€์‚ฐ(11:08~16:54) ์ž…์„ ์—ญ๋ฐœ๋งค์ค‘,
 [ITX-์ƒˆ๋งˆ์„] 8์›” 3์ผ, ์„œ์šธ~๋ถ€์‚ฐ(11:50~16:50) ์ž…์„ ์—ญ๋ฐœ๋งค์ค‘,
 [KTX] 8์›” 3์ผ, ์„œ์šธ~๋ถ€์‚ฐ(12:00~14:43) ํŠน์‹ค,์ผ๋ฐ˜์‹ค ์˜ˆ์•ฝ๊ฐ€๋Šฅ,
 [KTX] 8์›” 3์ผ, ์„œ์šธ~๋ถ€์‚ฐ(12:30~15:13) ํŠน์‹ค,์ผ๋ฐ˜์‹ค ์˜ˆ์•ฝ๊ฐ€๋Šฅ,
 [KTX] 8์›” 3์ผ, ์„œ์šธ~๋ถ€์‚ฐ(12:40~15:45) ํŠน์‹ค,์ผ๋ฐ˜์‹ค ์˜ˆ์•ฝ๊ฐ€๋Šฅ,
 [KTX] 8์›” 3์ผ, ์„œ์šธ~๋ถ€์‚ฐ(12:55~15:26) ํŠน์‹ค,์ผ๋ฐ˜์‹ค ์˜ˆ์•ฝ๊ฐ€๋Šฅ,
 [KTX] 8์›” 3์ผ, ์„œ์šธ~๋ถ€์‚ฐ(13:00~15:37) ํŠน์‹ค,์ผ๋ฐ˜์‹ค ์˜ˆ์•ฝ๊ฐ€๋Šฅ,
 [KTX] 8์›” 3์ผ, ์„œ์šธ~๋ถ€์‚ฐ(13:10~15:58) ํŠน์‹ค,์ผ๋ฐ˜์‹ค ์˜ˆ์•ฝ๊ฐ€๋Šฅ]

2-1. About passengers argument

passengers is a list(or tuple) of Passeger Objects. By this, you can search for multiple passengers. There are 3 types of Passengers now, AdultPassenger, ChildPassenger and SeniorPassenger.

# for 1 adult, 1 child
>>> psgrs = [AdultPassenger(), ChildPassenger()]

# for 2 adults, 1 child
>>> psgrs = [AdultPassenger(2), ChildPassenger(1)]
# ditto. They are being added each other by same group.
>>> psgrs = [AdultPassenger(), AdultPassenger(), ChildPassenger()]

# for 2 adults, 1 child, 1 senior
>>> psgrs = [AdultPassenger(2), ChildPassenger(), SeniorPassenger()]

# for 1 adult, It supports negative count or zero count. 
# But it uses passengers which the sum is greater than zero.
>>> psgrs = [AdultPassenger(2), AdultPassenger(-1)]
>>> psgrs = [AdultPassenger(), SeniorPassenger(0)]

# Nothing
>>> psgrs = [AdultPassenger(0), SeniorPassenger(0)]

# then search or reserve train
>>> trains = korail.search_train(dep, arr, date, time, passengers=psgrs)
...
>>> korail.reserve(trains[0], psgrs)
...

3. Make a reservation

You can get your tickets with tickets method.

>>> trains = korail.search_train(dep, arr, date, time)
>>> seat = korail.reserve(trains[0])
>>> seat
[KTX] 8์›” 23์ผ, ์„œ์šธ~๋™๋Œ€๊ตฌ(15:30~17:19) 42500์›(1์„), ๊ตฌ์ž…๊ธฐํ•œ 8์›” 18์ผ 14:05

Multiple.

>>> trains = korail.search_train(dep, arr, date, time)
>>> seat = korail.reserve(trains[0], passengers=psgrs)
>>> seat
[KTX] 8์›” 23์ผ, ์„œ์šธ~๋™๋Œ€๊ตฌ(15:30~17:19) 42500์›(3์„), ๊ตฌ์ž…๊ธฐํ•œ 8์›” 18์ผ 14:05

When tickets are not enough much for passengers, it raises SoldOutError.

If you want to select priority of seat grade, general or special, There are 4 options in ReserveOption class.

  • GENERAL_FIRST : Economic than Comfortable.
  • GENERAL_ONLY : Reserve only general seats. You are poorman ;-)
  • SPECIAL_FIRST : Comfortable than Economic.
  • SPECIAL_ONLY : Richman.
>>> korail.reserve(trains[0], psgrs, ReserveOption.GENERAL_ONLY)

4. Show reservations

You can get your tickes with tickets method.

>>> reservations = korail.reservations()
>>> reservations
[[KTX] 8์›” 23์ผ, ์„œ์šธ~๋™๋Œ€๊ตฌ(14:55~16:45) 42500์›(1์„), ๊ตฌ์ž…๊ธฐํ•œ 8์›” 18์ผ 14:03,
 [๋ฌด๊ถํ™”ํ˜ธ] 8์›” 23์ผ, ์„œ์šธ~๋™๋Œ€๊ตฌ(15:03~18:48) 21100์›(1์„), ๊ตฌ์ž…๊ธฐํ•œ 8์›” 18์ผ 14:03,
 [KTX] 8์›” 23์ผ, ์„œ์šธ~๋™๋Œ€๊ตฌ(15:30~17:19) 42500์›(1์„), ๊ตฌ์ž…๊ธฐํ•œ 8์›” 18์ผ 14:05]

5. Cancel reservation

You can also cancel your reservation using Reservation Object from reservations() call.

>>> korail.cancel(reservations[0])

6. Get tickets already paid

You can see your ticket list with tickets method. You can get the list of paid tickes with tickets method.

>>> korail = Korail("12345678", YOUR_PASSWORD, want_feedback=True)
>>> tickets = korail.tickets()
์ •์ƒ๋ฐœ๋งค์ฒ˜๋ฆฌ,์ •์ƒ๋ฐœ๊ถŒ์ฒ˜๋ฆฌ  # You can see these feedbacks when `want_feedback` is True.
>>> print tickets
[[KTX] 8์›” 10์ผ, ๋™๋Œ€๊ตฌ~์šธ์‚ฐ(09:26~09:54) => 5ํ˜ธ 4A, 13900์›]

Todo

  1. Implement payment API

License

Source codes are distributed under BSD license.

Author

Taehoon Kim / @carpedm20

Hanson Kim / @sng2c

More Repositories

1

awesome-hacking

A curated list of awesome Hacking tutorials, tools and resources
12,576
star
2

DCGAN-tensorflow

A tensorflow implementation of "Deep Convolutional Generative Adversarial Networks"
JavaScript
7,111
star
3

ENAS-pytorch

PyTorch implementation of "Efficient Neural Architecture Search via Parameters Sharing"
Python
2,626
star
4

emoji

emoji terminal output for Python
Python
1,877
star
5

deep-rl-tensorflow

TensorFlow implementation of Deep Reinforcement Learning papers
Python
1,578
star
6

DiscoGAN-pytorch

PyTorch implementation of "Learning to Discover Cross-Domain Relations with Generative Adversarial Networks"
Jupyter Notebook
1,048
star
7

NTM-tensorflow

"Neural Turing Machine" in Tensorflow
Jupyter Notebook
1,045
star
8

BEGAN-tensorflow

Tensorflow implementation of "BEGAN: Boundary Equilibrium Generative Adversarial Networks"
Python
920
star
9

MemN2N-tensorflow

"End-To-End Memory Networks" in Tensorflow
Python
826
star
10

LINE

May the LINE be with you...
Python
811
star
11

lstm-char-cnn-tensorflow

in progress
Python
756
star
12

awesome-torch

A curated list of awesome Torch tutorials, projects and communities
616
star
13

simulated-unsupervised-tensorflow

TensorFlow implementation of "Learning from Simulated and Unsupervised Images through Adversarial Training"
Python
573
star
14

variational-text-tensorflow

TensorFlow implementation of Neural Variational Inference for Text Processing
Python
545
star
15

pixel-rnn-tensorflow

in progress
Python
495
star
16

visual-analogy-tensorflow

Tensorflow implementation of "Deep Visual Analogy-Making"
Python
289
star
17

BEGAN-pytorch

in progress
Python
262
star
18

NAF-tensorflow

"Continuous Deep Q-Learning with Model-based Acceleration" in TensorFlow
Python
193
star
19

attentive-reader-tensorflow

in progress
Python
189
star
20

SPIRAL-tensorflow

in progress
Python
116
star
21

deep-learning-study

Study of HeXA@UNIST in Preparation for Submission
108
star
22

poet-neural

์ธ๊ณต์ง€๋Šฅ ์‹œํŒ”์ด, ์‹œ์ธ ๋‰ด๋Ÿด
CSS
76
star
23

karel

Karel dataset for program synthesis and program induction
Python
76
star
24

program-synthesis-rl-tensorflow

in progress
Python
72
star
25

text-based-game-rl-tensorflow

in progress
Python
61
star
26

paper-notes

personal notes
56
star
27

word2vec-tensorflow

in progress
Python
46
star
28

between

Between of VCNC for Python
Python
38
star
29

a3c-tensorflow

Python
33
star
30

hali

A neural network for question answering model
Lua
32
star
31

ndrive

Python wrapper for NAVER Ndrive
Python
31
star
32

RCMN

Recurrent Convolutional Memory Network (in progress)
Python
29
star
33

board

25
star
34

FoodClassifier

Food image classifier
Python
25
star
35

practice-tensorflow

Jupyter Notebook
20
star
36

reviewduk

Korean Sentiment Analyzer in Morphologically Rich Languages
JavaScript
19
star
37

voxoffice

A Data Visualization of Box Office History.
JavaScript
18
star
38

gornn

Deep Recurrent Neural Networks and Long Short Term Memory in Golang
Go
18
star
39

personal-blog-powered-by-flask

website powered by flask
Python
16
star
40

movieduk

Record the movie list and share it!
Python
15
star
41

movietag

Search movie with tag
CSS
12
star
42

HeXA-Bot

KakaoTalk robot which automatically answer to your command
Python
11
star
43

fraktur

convert the latin alphabet to fraktur unicode characters
Python
11
star
44

comgong-job

A robot for future computer science students
Python
9
star
45

carpedm20

7
star
46

naverdic

NAVER dictionary wrapper for Python
Python
7
star
47

neural-networks-and-deep-learning-ko

Translation of Neural Networks and Deep Learning by Michael Nielsen
6
star
48

ausung

A Data Visualization of Media Sentiments
JavaScript
6
star
49

Easily-written-Django

Easily learn Django to newbies of computer world
Python
6
star
50

Bias

Character-level Bidirectional LSTM for auto spacing (text segmentation)
Lua
5
star
51

quotes

JavaScript
5
star
52

nn-study

Lua
4
star
53

140min-python

140๋ถ„์˜ Python
JavaScript
4
star
54

i-crawl-news

i crawler news
Python
4
star
55

Run-Length-Prediction-of-Change-Point-by-Text-Features

Reading documents for bayesian Online Change Point Detection
HTML
4
star
56

ggomggom-email

Chrome extension for Korean grammer checker
JavaScript
4
star
57

korean-japanese-translator

Korean-Japanese translator using word2vec
Python
3
star
58

all-about-critics

A Data Visualization of Korean movie critics.
Python
3
star
59

jsSolar

Javascript solar system simulator
JavaScript
3
star
60

blog

CSS
3
star
61

UNIST-portal-bot

Facebook bot that uploads portal announcements automatically
Python
2
star
62

2014-study

2014-study
2
star
63

BufferTest_v2

Java
2
star
64

UNIST-FedEx

์œ ๋‹ˆ์ŠคํŠธ ๋‚ด๊ฐ€ ์ „ํ•ด์ฃผ๊นŒ
Python
2
star
65

bap-15min-before

๋ฐฅ๋จน๊ธฐ ์‹ญ์˜ค๋ถ„์ „ - ์œ ๋‹ˆ์ŠคํŠธ
Python
2
star
66

coursera-downloader

course material downloader from coursera
2
star
67

babo

๋ฐ”๋ณด (์‚ฌ์ „)
Python
2
star
68

movie-parser

movie parser
Python
2
star
69

random-wall

A jQuery plugin that randomly changes background-image of an element
JavaScript
2
star
70

basehangul

BaseHangul for GoLang
Go
2
star
71

vec2movie

Python
1
star
72

agora

Cloud commenting system.
Python
1
star
73

FoodDuk

Big data analysis for restaurant recommendation
JavaScript
1
star
74

Study-of-Computer-Vision

Study of Computer Vision
Python
1
star
75

UNIST-auction

UNIST auction
Python
1
star
76

UNIST-robot

easy to access UNIST portal, black board, library
C#
1
star
77

blackbot

blackbot
Python
1
star
78

comgong-abroad

A robot for future computer science students
Python
1
star
79

machine-learning

Study of Machine learning
Python
1
star
80

samantha

Python
1
star
81

FoodClassifier-matlab

Food image classifier written by Matlab
MATLAB
1
star