SRT(Super Rapid Train) wrapper for python
Project description
SRT
SRT(Super Rapid Train) application python wrapper
This project was inspired from korail2 of carpedm20.
Requirements
- Python >= 3.2
Installation
pip install SRTrain
Usage
1. Login
>>> from SRT import SRT
>>> srt = SRT("1234567890", YOUR_PASSWORD) # with membership number
>>> srt = SRT("def6488@gmail.com", YOUR_PASSWORD) # with email
>>> srt = SRT("010-1234-xxxx", YOUR_PASSWORD) # with phone number
use verbose
option to see some debugging messages
srt = SRT("010-1234-xxxx", YOUR_PASSWORD, verbose=True)
2. Searching trains
use search_train
method.
- 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
>>> dep = '수서'
>>> arr = '부산'
>>> date = '20180930'
>>> time = '144000'
>>> trains = srt.search_train(dep, arr, date, time)
>>> trains
# [[SRT] 09월 30일, 수서~부산(15:00~17:34) 특실 예약가능, 일반실 예약가능,
# [SRT] 09월 30일, 수서~부산(15:30~18:06) 특실 예약가능, 일반실 예약가능,
# [SRT] 09월 30일, 수서~부산(16:00~18:24) 특실 매진, 일반실 예약가능,
# [SRT] 09월 30일, 수서~부산(16:25~18:45) 특실 예약가능, 일반실 예약가능, ...]
3. Making a reservation
use reserve
method.
- train:
SRTTrain
object returned bysearch_train()
- passengers (optional, default is one Adult)
>>> trains = srt.search_train(dep, arr, date, time)
>>> reservation = srt.reserve(trains[0])
>>> reservation
# [SRT] 09월 30일, 수서~부산(15:30~18:06) 130700원(3석), 구입기한 09월 20일 23:38
>>> from passengers import Adult, Child
>>> srt.reserve(trains[1], passengers=[Adult(), Adult(), Child()])
Passenger class
Highly inspired by @dotaitch's Passenger class
- Adult
- Child
- Senior
- Disability1To3
- Disability4To6
4. Getting reserved tickets
Use get_reservations()
method.
>>> reservations = srt.get_reservations()
>>> reservations
# [[SRT] 09월 30일, 수서~부산(15:30~18:06) 130700원(3석), 구입기한 09월 19일 19:11]
>>> reservations[0].tickets
# [18호차 9C (일반실) 어른/청소년 [52300원(600원 할인)],
# 18호차 10C (일반실) 어른/청소년 [52300원(600원 할인)],
# 18호차 10D (일반실) 장애 4~6급 [26100원(26800원 할인)]]
5. Canceling reservation
Use cancel
method.
- reservation:
SRTreservation
object returned byreserve()
or returned byget_reservations()
>>> reservation = srt.reserve(train)
>>> srt.cancel(reservation)
>>> reservations = srt.get_reservations()
>>> srt.cancel(reservations[0])
TODO
- Add tests for CI
- PyPI
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
SRTrain-0.1.2.tar.gz
(12.0 kB
view details)
File details
Details for the file SRTrain-0.1.2.tar.gz
.
File metadata
- Download URL: SRTrain-0.1.2.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.13.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.5.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3020dade942eb93dcd87113bcc5fb2f8a56117688166efa30a5d591dcb7f5f58 |
|
MD5 | e055b0dc2f861171d593ed65dc3d8b9a |
|
BLAKE2b-256 | 18cb12be3a763b602f3699a4c87812dd68eab3ad12f94b2955732709de268eaf |