Skip to main content

12306查票助手,一键查询沿途所有站点,在买不到票的时候,先上车后补票,暂不支持抢票

Project description

x12306

12306查票助手,主要功能是可以一键查询沿途所有站点。

当全程票售罄的时候,方便查询中间站点余票,先上车后补票。

工具仅用于查询余票,不支持购票,建议在12306官方平台购票。

仅支持Python3,推荐Python3.5+

使用前需要修改glovar.py中的QUERY_URLJSESSIONID

获取QUERY_URL和JSESSIONID

  1. 打开浏览器,访问 https://www.12306.cn/index/
  2. 随便查询一个车次,如上海 > 北京
  3. 按F12(或CMD+Option+I)打开浏览器控制台,打开网络(Network)选项卡
  4. 找到查询车次的请求,如果没找到,可以再点一下查询
  5. glovar.py中修改QUERY_URLJSESSIONID

安装运行

手动安装:

git clone https://github.com/0xHJK/x12306
cd x12306 && make install

不安装直接运行:

git clone https://github.com/0xHJK/x12306
cd x12306
python3 x12306.py -f <出发地> -t <目的地> -d <YYYY-MM-DD> -z

使用方法

$ x12306 --help
Usage: x12306.py [OPTIONS]

  12306查票助手 https://github.com/0xHJK/x12306

  Example:python x12306.py -f 上海 -t 北京 -d "2019-03-01" -n "G16 G18 G22" -r

  如果查询失败的话,请修改glovar.py中的QUERY_URL和JSESSIONID

Options:
  --version                Show the version and exit.
  -f, --from-station TEXT  出发地
  -t, --to-station TEXT    目的地
  -d, --date TEXT          日期
  -s, --seats TEXT         限制座位
  -n, --train-no TEXT      限制车次
  -z, --zmode              高级模式,查询中间站点
  -zz, --zzmode            终极模式,查询所有中间站点
  -r, --remaining          只看有票
  --gcd                    只看高铁动车城际
  --ktz                    只看普快特快直达等
  --proxies-file TEXT      代理列表文件
  --stations-file TEXT     站点信息文件
  --cdn-file TEXT          CDN文件
  --help                   Show this message and exit.

使用示例

LICENSE

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

x12306-0.2.1.tar.gz (74.1 kB view hashes)

Uploaded Source

Built Distribution

x12306-0.2.1-py3-none-any.whl (73.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page