GithubHelp home page GithubHelp logo

stcp-notifier's Introduction

Node STCP notifier CLI

Very simple Node.js application to scrap the STCP website to get the ETA of the next buses at a bus stop.

Motivation

With this application I don't have to keep refreshing their website and I can get a notification when I need to get out to the bus stop. This way I don't loose my bus and I don't need to waste time waiting at the stop. ๐Ÿ˜„

Functionality

What it does:

  • automatic requests every 30 seconds;
  • filter results to a specific line;
  • set notifications when bus is less than x minutes away.

Demonstration

Demonstration gif

Explanation

STCP provides a tool to see the remaining times of the buses at any of its bus stations.

The tool functions with unique station codes. For example: AAL1 in http://www.stcp.pt/pt/viajar/horarios/?paragem=AAL1&t=smsbus

Peeking at the source code of the page, it was possible to discover a more stripped-down version of this tool at http://www.stcp.pt/itinerarium/soapclient.php?codigo=AAl1 which returns very little HTML and the information about the next buses. Here is an example of the returned HTML:

<div id="smsBusHeader">
  <div class="filtro">
    [...]
  </div>
</div>
<table id="smsBusResults" width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr>
    <th>Linha</th>
    <th>Hora Prevista</th>
    <th>Tempo de Espera</th>
  </tr>
  <tr class="even">
    <td>
      <ul class="linhasAssoc">
        <li><a target="_self" class="linha_4m" title="" href="/pt/viajar/linhas/?linha=4M ">4M </a></li>
      </ul>
      &nbsp;AV. ALIADOS
    </td>
    <td><i>00:49</i></td>
    <td>3min</td>
  </tr>
  <tr class="even">
    <td>
      <ul class="linhasAssoc">
        <li><a target="_self" class="linha_3m" title="" href="/pt/viajar/linhas/?linha=3M ">3M </a></li>
      </ul>
      &nbsp;AV. ALIADOS
    </td>
    <td><i>00:53</i></td>
    <td>7min</td>
  </tr>
</table>

The information we want is in the table with id smsBusResults in each of its rows with class even.

Getting Started

  1. Clone or download this repo;

  2. Open the directory in terminal;

  3. Install Node modules with npm install;

  4. Run the Node application with node stcp.js <bus stop code>.

  5. For easier usage, you can link the module with npm link; now you can use the CLI with just stcp <bus stop code>.

stcp-notifier's People

Contributors

clinis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

ampc

stcp-notifier's Issues

User preferences

Allow user to set some preferences:

  • set personalized labels for bus stops (for example: home, work, school, etc.);
  • set notification time interval

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.