# HK Bus Crawling (a.k.a. hk-bus-eta)
[![Python 3.8.8](https://img.shields.io/badge/python-3.8.8-blue.svg)](https://www.python.org/downloads/release/python-388/) ![Data fetching status](https://github.com/hkbus/hk-bus-crawling/actions/workflows/fetch-data.yml/badge.svg)
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](https://www.npmjs.com/package/hk-bus-eta).
### Installation
To install the package,
```sh
pip install hk-bus-eta
```
## Usage
**Fetch ETAs of a route**
```python
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**
```python
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](https://github.com/hkbus/hk-bus-crawling/tree/gh-pages) or direct download [here](https://hkbus.github.io/hk-bus-crawling/routeFareList.min.json)
### 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](https://github.com/hkbus/route-waypoints)
## Contributors
[ChunLaw](http://github.com/chunlaw/)
Raw data
{
"_id": null,
"home_page": "",
"name": "hk-bus-eta",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "python,hongkong,eta,estimated time of arrival,kmb,nlb,mtr,ctb,minibus,lightrail",
"author": "Chun Law (chunalw)",
"author_email": "<chunlaw@rocketmail.com.com>",
"download_url": "https://files.pythonhosted.org/packages/22/d3/c56963bdf4dbc79f14ee6642a0b2f66fc87b73a942d176f07e0b0d1d0a50/hk-bus-eta-2.1.6.tar.gz",
"platform": null,
"description": "\n# HK Bus Crawling (a.k.a. hk-bus-eta)\n\n[![Python 3.8.8](https://img.shields.io/badge/python-3.8.8-blue.svg)](https://www.python.org/downloads/release/python-388/) ![Data fetching status](https://github.com/hkbus/hk-bus-crawling/actions/workflows/fetch-data.yml/badge.svg) \n\nThis 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.\n\n## Fetching Transport ETA\n\nThe package is a python vertion for the npm package [hk-bus-eta](https://www.npmjs.com/package/hk-bus-eta).\n\n### Installation\nTo install the package,\n\n```sh\npip install hk-bus-eta\n```\n\n## Usage\n\n**Fetch ETAs of a route**\n```python\nfrom hk_bus_eta import HKEta\n\nhketa = HKEta()\netas = hketa.getEtas(route_id = \"TCL+1+Hong Kong+Tung Chung\", seq=0, language=\"en\")\nprint (etas)\n\n\"\"\"\n[{'eta': '2023-09-12T11:43:00+08:00', 'remark': {'zh': '1\u865f\u6708\u53f0', 'en': 'Platform 1'}, 'co': 'mtr'}, {'eta': '2023-09-12T11:51:00+08:00', 'remark': {'zh': '1\u865f\u6708\u53f0', 'en': 'Platform 1'}, 'co': 'mtr'}, {'eta': '2023-09-12T11:58:00+08:00', 'remark': {'zh': '1\u865f\u6708\u53f0', 'en': 'Platform 1'}, 'co': 'mtr'}, {'eta': '2023-09-12T12:05:00+08:00', 'remark': {'zh': '1\u865f\u6708\u53f0', 'en': 'Platform 1'}, 'co': 'mtr'}]\n\"\"\"\n```\n\n**List Route IDs**\n```python\nfrom hk_bus_eta import HKEta\n\nhketa = new HKEta()\nroute_ids = list( hketa.route_list.keys() )\nprint( route_ids )\n\n\"\"\"\n['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)']\n\"\"\"\n```\n\n\n## Crawling by yourself\n\n### Usage\nDaily fetched JSON is in [gh-pages](https://github.com/hkbus/hk-bus-crawling/tree/gh-pages) or direct download [here](https://hkbus.github.io/hk-bus-crawling/routeFareList.min.json)\n\n### Installation\n\nTo install the dependencies,\n```\npip install -r ./crawling/requirements.txt\n```\n\n### Data Fetching\n\nTo fetch data, run the followings,\n```\npython ./crawling/parseHoliday.py\npython ./crawling/ctb.py\npython ./crawling/kmb.py\npython ./crawling/nlb.py\npython ./crawling/lrtfeeder.py\npython ./crawling/lightRail.py\npython ./crawling/mtr.py\npython ./crawling/parseJourneyTime.py\npython ./crawling/parseGtfs.py\npython ./crawling/gmb.py\npython ./crawling/matchGtfs.py\npython ./crawling/cleansing.py\npython ./crawling/mergeRoutes.py\n```\n\n## Citing \n\nPlease kindly state you are using this app as\n`\nHK Bus Crawling@2021, https://github.com/hkbus/hk-bus-crawling\n`\n\n## Waypoint data\n\nYou may refer to the repository [HK Bus WayPoints Crawling](https://github.com/hkbus/route-waypoints)\n\n## Contributors\n[ChunLaw](http://github.com/chunlaw/)\n",
"bugtrack_url": null,
"license": "",
"summary": "Query the ETA (Estimated Time of Arrival) of HK Bus/Minibus/MTR/Lightrail",
"version": "2.1.6",
"project_urls": null,
"split_keywords": [
"python",
"hongkong",
"eta",
"estimated time of arrival",
"kmb",
"nlb",
"mtr",
"ctb",
"minibus",
"lightrail"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ceaa328a9935b590ced002e8b4c449632dac56df97e617c1424a4d87812b2719",
"md5": "8f9528c2166ac51ce60a79568b7db9eb",
"sha256": "cc8c9e58e81cf4b868f7f64a2dec771c14ea93000c5d3fda69536f94b262fc3a"
},
"downloads": -1,
"filename": "hk_bus_eta-2.1.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8f9528c2166ac51ce60a79568b7db9eb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 12476,
"upload_time": "2024-01-24T05:28:09",
"upload_time_iso_8601": "2024-01-24T05:28:09.886894Z",
"url": "https://files.pythonhosted.org/packages/ce/aa/328a9935b590ced002e8b4c449632dac56df97e617c1424a4d87812b2719/hk_bus_eta-2.1.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "22d3c56963bdf4dbc79f14ee6642a0b2f66fc87b73a942d176f07e0b0d1d0a50",
"md5": "d9898ea0d7aeabbcc6ba1d92b106f8a6",
"sha256": "a7aa1f2257139d00f16a36b0a8b054fb46006728faa929f6348edb6b368a48b8"
},
"downloads": -1,
"filename": "hk-bus-eta-2.1.6.tar.gz",
"has_sig": false,
"md5_digest": "d9898ea0d7aeabbcc6ba1d92b106f8a6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 11884,
"upload_time": "2024-01-24T05:28:11",
"upload_time_iso_8601": "2024-01-24T05:28:11.695009Z",
"url": "https://files.pythonhosted.org/packages/22/d3/c56963bdf4dbc79f14ee6642a0b2f66fc87b73a942d176f07e0b0d1d0a50/hk-bus-eta-2.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-24 05:28:11",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "hk-bus-eta"
}