命令行查火车票

发布于 2018-10-06 19:29:45

依赖

  • tuniu.py
  • pip3 install pretty-format-json printable
  • xsv: brew install xsv

Bash 脚本

sort-filter-tuniu-train-info() {
    # brew install xsv
    # pip3 install pretty-format-json printable
    # accept json data from tuniu.py
    csv_json | xsv sort -s sellOut,trainTypeName,departDepartTime,trainNum | xsv select trainNum,sellOut,trainTypeName,departStationName,destStationName,trainStartDate,departDepartTime,destArriveTime,durationStr,memo,price_0-price_3 | csv_json | printable --grid full --less
}

get-train-info-from-tuniu() {
    if [[ "$@" == "-h" || "$@" == "" ]]; then
        tuniu -h
        return 1
    fi
    tuniu $@ | sort-filter-tuniu-train-info
}

效果

$ get-train-info-from-tuniu 长沙 深圳 -d 2018-10-12

comments powered by Disqus