Node.js 的车票 SDK

2014-12-31 15:54:50 +08:00
 fanTasy
项目地址: 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!
2300 次点击
所在节点    Node.js
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/158228

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX