# mtr-lines-scraper

> Retrieve heavy rail and light rail lines and stations from the MTR company easily!

Latest version **0.1.0** (published 2019-08-14) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install mtr-lines-scraper
pnpm add mtr-lines-scraper
yarn add mtr-lines-scraper
bun add mtr-lines-scraper
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2019-08-14 |
| First published | 2019-08-14 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 69.3 KB |
| Known vulnerabilities | 0 (+25 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jason Kwok |
| Maintainers | jasonhk |
| Keywords | mtr |

## Links

- npm: https://www.npmjs.com/package/mtr-lines-scraper
- Repository: https://github.com/JasonHK/node-mtr-lines-scraper
- Homepage: https://github.com/JasonHK/node-mtr-lines-scraper#readme
- Issues: https://github.com/JasonHK/node-mtr-lines-scraper/issues
- npm.io page: https://npm.io/package/mtr-lines-scraper

## Dependencies (5)

- [axios](https://npm.io/package/axios.md) ^0.19.0
- [tslib](https://npm.io/package/tslib.md) ^1.10.0
- [cheerio](https://npm.io/package/cheerio.md) ^1.0.0-rc.3
- [is-what](https://npm.io/package/is-what.md) ^3.2.4
- [map-to-obj](https://npm.io/package/map-to-obj.md) ^0.2.0

## Recent versions

- 0.1.0 (latest) — 2019-08-14

## README

mtr-lines-scraper
=================

Retrieve heavy rail and light rail lines and stations from [the MTR company][mtr-website] easily!

[![npm-version-badge]][npm-package] [![npm-download-badge]][npm-package] [![github-license-badge]][github-license]

## Installation


```sh
$ npm install mtr-lines-scraper
```

## Usage

### Retrieve railway data from MTR

```javascript
const { getRailwayDetails } = require("mtr-lines-scraper");

getRailwayDetails()
    .then((details) => {
        // Do whatever you want here.
        console.log(details.heavyRail);
        console.log(details.lightRail);
    });
```

### Using railway data from local cache

#### Synchronous method

```javascript
const { readFileSync } = require("fs");
const { getRailwayDetailsSync } = require("mtr-lines-scraper");

// Assume the cache does exist.
const cache = JSON.parse(readFileSync("cache.json", "utf8"));

// Retrieve railway details synchronously.
const details = getRailwayDetailsSync(cache);

// Do whatever you want here.
console.log(details.heavyRail);
console.log(details.lightRail);
```

#### Asynchronous method

```javascript
const { readFileSync } = require("fs");
const { getRailwayDetailsSync } = require("mtr-lines-scraper");

// Assume the cache does exist.
const cache = JSON.parse(readFileSync("cache.json", "utf8"));

// Retrieve railway details asynchronously.
getRailwayDetails(cache)
    .then((details) => {
        // Do whatever you want here.
        console.log(details.heavyRail);
        console.log(details.lightRail);
    });
```

[github-license]: https://github.com/JasonHK/node-mtr-lines-scraper/blob/master/LICENSE
[github-license-badge]: https://img.shields.io/github/license/JasonHK/node-mtr-lines-scraper?style=flat-square
[github-documentation]: https://github.jasonhk.net/node-mtr-lines-scraper

[npm-package]: https://www.npmjs.com/package/mtr-lines-scraper
[npm-download-badge]: https://img.shields.io/npm/dt/mtr-lines-scraper?style=flat-square
[npm-version-badge]: https://img.shields.io/npm/v/mtr-lines-scraper?style=flat-square

[mtr-website]: http://www.mtr.com.hk

---
_Source: https://npm.io/package/mtr-lines-scraper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
