Giter VIP home page Giter VIP logo

12306's Introduction

Nodejs版 12306查询余票小工具

一个 Nodejs 写的查询12306余票的小工具,查询到指定车次的车票后会反馈到邮箱

git地址:https://github.com/isxiaoxin/12306

已实现的功能

  • 根据中文站点名称去查找对应的站点代号

  • 支持查询单个/多个车次数据

  • 定时监控余票数量

  • 检测到指定车次票数的变化后发送新结果到邮箱

使用方法

1、把代码克隆到本地

$ git clone https://github.com/isxiaoxin/12306.git

2、安装依赖

$ npm install
// 或 yarn install

3、配置 config.js 内的信息

车次信息需要自行到12306网站搜集

date: '2020-09-03', // 出发日期 格式:yyyy-mm-dd 如:2020-08-31
from: '广州', // 起始站中文
to: '郴州', // 到达站中文
type: 'ADULT', // 乘客类型 成人:ADULT,学生:0X00
trainNo: 'G822', // 需要监测的车次 多个车次用|隔开 如:G822|G1112 可忽略大小写
mail: '', // 邮箱地址 默认是qq邮箱 其他邮箱需要改nodemailer的配置
pass: '', // 邮箱的smtp授权码 不是qq密码 放心填写

4、执行命令

node start.js

执行之后是这样的 终端也能看到此次查询的信息 this.logger 为true时会输出 可自行更改

image-20200903101729933

默认每隔1分钟查询余票,有需要可自行调整 start.js 里的 this.interval

检测到余票后会收到这样一个邮件,可自行调整邮件模板或样式

小鑫

其他

  • 在不使用进程守护的情况下只能通过 ctrl + c 关闭查询(小菜鸡没用过 mac 哈哈)

  • 有需要进程守护的可自行使用 pm2 - https://www.jianshu.com/p/e15fd72727fe

  • 如果 setInterval 满足不了需求可自行使用 node-schedule

最后

目前只是实现出来第一版,有任何问题或建议可以给我提 issue 或者咨询我,代码里有我的联系方式噢~

12306's People

Contributors

isxiaoxin avatar

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.