This project fetches bus route information for KMB, CTB, NLB, minibus, MTR, and lightrail. The crawled route, stop, service-day, holiday, and nearby-stop data is published as separate JSON files in gh-pages.
The package is a python version for the npm package hk-bus-eta.
To install the package,
pip install hk-bus-eta
Fetch ETAs of a route
from hk_bus_eta 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
from hk_bus_eta 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)']
"""
Daily fetched JSON is in gh-pages, including integrated_routes.json, operators_stops.json, nearby_operators_stops.json, service_days.json, and holidays.json.
Use poetry to install the dependencies to your environment:
poetry install --no-root
To fetch data, run the followings,
poetry run python ./crawling/parseJourneyTime.py
poetry run python ./crawling/parseGtfs.py
poetry run python ./crawling/parseHoliday.py
poetry run python ./crawling/ctb_crawl.py
poetry run python ./crawling/ctb.py
poetry run python ./crawling/kmb_crawl.py
poetry run python ./crawling/kmb.py
poetry run python ./crawling/nlb_crawl.py
poetry run python ./crawling/nlb.py
poetry run python ./crawling/lrtfeeder.py
poetry run python ./crawling/lightRail.py
poetry run python ./crawling/mtr.py
poetry run python ./crawling/sunferry.py
poetry run python ./crawling/fortuneferry.py
poetry run python ./crawling/hkkf.py
poetry run python ./crawling/gmb_crawl.py
poetry run python ./crawling/gmb.py
poetry run python ./crawling/matchGtfs.py
poetry run python ./crawling/cleansing.py
poetry run python ./crawling/mergeRoutes.py
Please kindly state you are using this app as ` HK Bus Crawling@2021, https://github.com/hkbus/hk-bus-crawling `
You may refer to the repository HK Bus WayPoints Crawling