资源简介
python实现的tkinter窗口版的火车票查询软件,可支持15天内的火车票查询,但必须在有网的环境中运行,压缩文件中的api.py和ticket.py必须在统一路径下才可以
代码片段和文件信息
import datetime
import requests
station_url = ‘https://kyfw.12306.cn/otn/resources/js/framework/station_name.js?station_version=1.9050‘
r=requests.get(station_url)
station_list=r.text.split(“@“)
stations=[]
for i in station_list[1:]:
s1=i.split(“|“)
s2=[s1[2]s1[1]s1[0]s1[3]]
stations.append(s2)
dates=[]
today=datetime.date.today()
for i in range(015):
date=today+datetime.timedelta(days=i)
dates.append(str(date))
def station_valid(stations station):
for st in stations:
if station in st[1:]:
return False
return True
def station_output(stationsstation):
for st in stations:
if station in st:
return st[1]
def station_code(stations station):
for st in stations:
if station in st:
return st[0]
def date_valid(datedates):
if date in dates:
return False
else:
return True
def ticket_query(from_station to_station from_date):
ticket_url = ‘https://kyfw.12306.cn/otn/leftTicket/queryO?leftTicketDTO.train_date=%s&leftTicketDTO.from_station=%s&leftTicketDTO.to_station=%s&purpose_codes=ADULT‘ % (from_date from_station to_station)
#print(ticket_url)
ticketdic = requests.get(ticket_url).json()
ticket_list = ticketdic[‘data‘][‘result‘]
tickets = []
for t in ticket_list:
ta = t.split(‘|‘)
if ta[0] == ‘null‘:
continue
train_no = ta[2]
checi = ta[3]
shifazhan = ta[4]
zhongdian = ta[5]
chufazhan = ta[6]
daodazhan = ta[7]
chufashijian = ta[8]
daodashijian = ta[9]
lishi = ta[10]
train_date = ta[13]
from_station_no = ta[16]
to_station_no = ta[17]
gaojiruanwo = ta[21]
ruanwo = ta[23]
wuzuo = ta[26]
yingwo = ta[28]
yingzuo = ta[29]
erdengzuo = ta[30]
yidengzuo = ta[31]
shangwuzuo = ta[25] or ta[32]
dongwo = ta[33]
seat_types = ta[35]
station = ‘-‘.join([station_output(stations chufazhan) station_output(stations daodazhan)])
qtime = ‘-‘.join([chufashijian daodashijian])
tickets.append([checistationqtimelishishangwuzuoyidengzuoerdengzuoruanwodongwoyingwoyingzuowuzuofrom_date])
return tickets
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-04-05 16:20 火车票\
目录 0 2018-04-05 16:20 火车票\__pycache__\
文件 2399 2018-03-23 13:55 火车票\__pycache__\api.cpython-36.pyc
文件 2150 2018-03-23 11:04 火车票\api.py
文件 1524 2018-03-22 10:35 火车票\demo4.py
文件 4520 2018-03-24 19:15 火车票\demo5.py
文件 1227 2018-03-17 10:05 火车票\record.txt
文件 2941 2018-03-21 12:10 火车票\ticket.py
文件 2822 2018-03-22 10:37 火车票\train.py
相关资源
- python安装器easy_install
- selenium最新版2.53.1---python
- python Tkinter
- 批量文件.py
- 一套最新价值1680元的python爬虫实战全
- 测试工程师相关学习视频(包含pyth
- Building Django 2.0 Web Applications
- 轻量级PythonWeb框架Mole.zip
- 谁说菜鸟不用数据分析
- Python源码剖析★PART2★(完整清晰版
- mysqlclient-1.3.13-cp36-cp36m-win32.whl
- Python-一系列高品质的动漫人脸数据集
- Python-Insightface人脸检测识别的最小化
- 非线性回归Python代码
- python 使用pandas操作EXCEL表格数据
- 卷积神经网络图像识别python代码pdf
- pytorch_pose_proposal_networks-master.zip
- 关于吃豆人的游戏代码python
- 基于Python的离线Google地图操作实现
- 11-Python爬虫工程师-App抓取进阶
- 093 2018北风网人工智能视频(完结)转
- Python+OpenCv项目代码
- 疯狂Python讲义_李刚_2019
- Python实现高斯投影正反算
- 100行python代码 帮你实现同花顺A股下单
- 用python实现sm2国密算法
- python 识别物体跟踪
- Python黑客攻防入门
- Python黑帽子(黑客与渗透测试编程之
- 通过python使用opencv计算图像的中心
评论
共有 条评论