V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
fanTasy
V2EX  ›  Node.js

Node.js 的车票 SDK

  •  
  •   fanTasy · 2014-12-31 15:54:50 +08:00 · 2288 次点击
    这是一个创建于 3411 天前的主题,其中的信息可能已经有所发展或是发生改变。
    项目地址: https://github.com/SFantasy/node-chepiao-sdk
    取名chepiao-sdk是因为使用的是che100网站的API。

    个人通过邮箱申请的key有效期为1周,现在写好了两个接口:

    根据车次获取列车时刻
    根据日期、起始站点获取余票信息
    以下是项目的README:

    Install

    npm install chepiao-sdk --save

    Usage

    Register and get your userid and seckey: chepiao100.com

    Initialize the SDK

    var Chepiao = require('chepiao-sdk');
    var chepiao = new Chepiao({
    userid: 'your userid',
    seckey: 'your secret key'
    });

    Use the API

    chepiao.schedule('g1', function (res) {
    // do stuff with the response
    });

    然后我用这个SDK做了一个简单的通过命令行查询列车时刻的工具(不过由于不好在命令行里处理表格,所以现在有点乱乱的感觉): https://github.com/SFantasy/node-train

    可以通过 npm install cntrain -g 来安装

    通过 cntrain -n g1 这样的命令就能在命令行中查看指定列车的时刻表。

    最后,欢迎各位大大吐槽。喜欢的同学欢迎 star && fork!
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1046 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 18:10 · PVG 02:10 · LAX 11:10 · JFK 14:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.