Skip to main content

HK Bus Crawling (a.k.a. hk-bus-eta)

Python 3.8.8 Data fetching status

This project is to fetch the bus route information of KMB, CTB, NLB, 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

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)']
"""

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

Waypoint data

You may refer to the repository HK Bus WayPoints Crawling

Contributors

ChunLaw

Release files for hk-bus-eta 2.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hk-bus-eta 2.1.6
File Size Uploaded
hk-bus-eta-2.1.6.tar.gz 11.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hk-bus-eta 2.1.6
File Interpreter ABI Platform
hk_bus_eta-2.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 24.4 kB

Release files / hk-bus-eta-2.1.6.tar.gz

Download URL hk-bus-eta-2.1.6.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a7aa1f2257139d00f16a36b0a8b054fb46006728faa929f6348edb6b368a48b8
BLAKE2b-256 checksum
How to use checksums
22d3c56963bdf4dbc79f14ee6642a0b2f66fc87b73a942d176f07e0b0d1d0a50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.16

Release files / hk_bus_eta-2.1.6-py3-none-any.whl

Download URL hk_bus_eta-2.1.6-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cc8c9e58e81cf4b868f7f64a2dec771c14ea93000c5d3fda69536f94b262fc3a
BLAKE2b-256 checksum
How to use checksums
ceaa328a9935b590ced002e8b4c449632dac56df97e617c1424a4d87812b2719
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.16

Release history Release notifications | RSS feed

This release

2.1.6 This release

2 release files

2.1.5

2 release files

2.1.4

2 release files

1.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page