Query the ETA (Estimated Time of Arrival) of HK Bus/Minibus/MTR/Lightrail
Project description
HK Bus Crawling (a.k.a. hk-bus-eta)
This project is to fetch the bus route information of KMB, CTB, minibus, MTR, lightrail into one single JSON. It is daily synced to data.gov.hk and launched in gh-pages.
Fetching Transport ETA
The package is a python vertion for the npm package hk-bus-eta.
Installation
To install the package,
pip install hk-bus-eta
Usage
Fetch ETAs of a route
import HKEta
hketa = HKEta()
etas = hketa.getEtas(route_id = "TCL+1+Hong Kong+Tung Chung", seq=0, language="en")
print (etas)
"""
[{'eta': '2023-09-12T11:43:00+08:00', 'remark': {'zh': '1號月台', 'en': 'Platform 1'}, 'co': 'mtr'}, {'eta': '2023-09-12T11:51:00+08:00', 'remark': {'zh': '1號月台', 'en': 'Platform 1'}, 'co': 'mtr'}, {'eta': '2023-09-12T11:58:00+08:00', 'remark': {'zh': '1號月台', 'en': 'Platform 1'}, 'co': 'mtr'}, {'eta': '2023-09-12T12:05:00+08:00', 'remark': {'zh': '1號月台', 'en': 'Platform 1'}, 'co': 'mtr'}]
"""
List Route IDs
import HKEta
hketa = new HKEta()
route_ids = list( hketa.route_list.keys() )
print( route_ids )
"""
['1+1+CHUK YUEN ESTATE+STAR FERRY', '1+1+Central (Hong Kong Station Public Transport Interchange)+The Peak (Public Transport Terminus)', '1+1+Felix Villas+Happy Valley (Upper)', '1+1+Happy Valley (Upper)+Felix Villas', '1+1+Kowloon Bay (Telford Gardens)+Sai Kung', '1+1+Mui Wo Ferry Pier+Tai O', '1+1+STAR FERRY+CHUK YUEN ESTATE', '1+1+Sai Kung+Kowloon Bay (Telford Gardens)', '1+1+Tai O+Mui Wo Ferry Pier', '1+1+The Peak (Public Transport Terminus)+Central (Hong Kong Station Public Transport Interchange)']
"""
Crawling by yourself
Usage
Daily fetched JSON is in gh-pages or direct download here
Installation
To install the dependencies,
pip install -r ./crawling/requirements.txt
Data Fetching
To fetch data, run the followings,
python ./crawling/parseHoliday.py
python ./crawling/ctb.py
python ./crawling/kmb.py
python ./crawling/nlb.py
python ./crawling/lrtfeeder.py
python ./crawling/lightRail.py
python ./crawling/mtr.py
python ./crawling/parseJourneyTime.py
python ./crawling/parseGtfs.py
python ./crawling/gmb.py
python ./crawling/matchGtfs.py
python ./crawling/cleansing.py
python ./crawling/mergeRoutes.py
Citing
Please kindly state you are using this app as
HK Bus Crawling@2021, https://github.com/hkbus/hk-bus-crawling
Contributors
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hk-bus-eta-2.1.4.tar.gz
(12.0 kB
view hashes)
Built Distribution
hk_bus_eta-2.1.4-py3-none-any.whl
(12.3 kB
view hashes)
Close
Hashes for hk_bus_eta-2.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | edba1f12141c08eea6662f4cf5f934f3e2a2ae4c9de989a55df1b2b871f86c4d |
|
MD5 | 89df4e699c8cd871703e0ba6134a311d |
|
BLAKE2b-256 | 25056ee49afb5ef6c7c57809d4940450c713426cd1d2cb6bd35d9b29b749dfbe |