Giter Site home page Giter Site logo

node_12306's Introduction

node_12306

目前已重新支持使用,如有功能需求建议,可在issue里提

适用场景:

已经确定了火车的车次和时间(最好提前3-4天),但是没有座位了。想抢有座位的(只能抢别人的退票了,几天内一般都会有人退票)。

使用方法:

  • 克隆代码到本地git clone https://github.com/hongrunhui/node_12306.git
  • 在当前文件夹终端npm install安装依赖
  • node main.js,第一次运行会要求输入信息并且存入config.json,以后再次运行只会读取config.json中的数据,不会要求再次输入。如:
    image
  • 运行结果如下:
    image
  • node main.js -r可以重写config.json(重新输入信息)。
  • node main.js -t可以更新车站信息,当然也要看station_name.js的station_version。
  • 车次(train_num字段)可以输入多个车次,用|分开,如K123|K234(前提这些车次都在同一线路上)。
  • 12306检测到余票查询这个接口有大流量的时候,会更换余票查询的地址,所以才会报错,现在自动爬取这个地址,应该不会报错,输入的问题也解决了,后续研究研究怎么自动下单(不过要实现这个应该不简单= =,我工作也很忙呀)。

注意:

  • 要使用邮件功能前提是要去邮箱设置里开启smtp;也可以用邮箱授权码代替,这种方式更安全。具体可以见wiki
  • 针对有人提出程序可能会报错退出的问题,这里建议使用pm2来启动main.js,具体步骤:
    • npm install pm2 -g全局安装pm2
    • [sudo] pm2 start main.js启动程序(linux可能会需要管理员权限)
    • [sudo] pm2 list列出当前程序的运行情况
    • [sudo] pm2 stop停止程序
    • 大家可以放到自己的服务器上面去运行,这样全天24小时都可以监听你的车次还有没有票,并及时给你发邮件。
  • 有人提出自动抢票下单支付功能,这个我以后会想办法去实现。
  • 博客地址

声明

  • 本程序最适合监听那些一张票都没有的车次(或者无座多,硬座/软座/硬卧/软卧无的车次),通过本程序可以24小时监听车次是否会多出余票,并及时发送邮件通知个人(可以使用pm2部署在自己的服务器上或24小时开着电脑运行实现24小时监听)
  • 对于有特殊需求的可以自己修改代码或者咨询我。

node_12306's People

Contributors

hongrunhui avatar 2222804 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.