Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
janlyn06
12306
提交
2f071287
1
12306
项目概览
janlyn06
/
12306
通知
4
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
1
12306
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
2f071287
编写于
1月 14, 2019
作者:
W
wenxianping
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改已知bug
issues:
https://github.com/testerSunshine/12306/issues/177
上级
941cbe68
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
24 addition
and
15 deletion
+24
-15
README.md
README.md
+2
-0
config/configCommon.py
config/configCommon.py
+3
-2
config/ticket_config.yaml
config/ticket_config.yaml
+13
-12
init/select_ticket_info.py
init/select_ticket_info.py
+5
-0
inter/Query.py
inter/Query.py
+1
-1
未找到文件。
README.md
浏览文件 @
2f071287
...
...
@@ -80,10 +80,12 @@
-
学生票issues
[
学生票修改
](
https://github.com/testerSunshine/12306/issues/47
)
-
依赖安装不对的问题(ImportError)
[
requirements.txt问题
](
https://github.com/testerSunshine/12306/issues/91
)
-
若快豆子疑问
[
点我
](
https://github.com/testerSunshine/12306/issues/67
)
-
IOError: 【Errno 0】 Error 问题
[
点我
](
https://github.com/testerSunshine/12306/issues/159
)
- 测试下单接口是否可用,有两个下单接口,随便用哪个都ok
- 如果下载验证码过期或者下载失败的问题,应该是12306封ip的策略,多重试几次,12306现在封服务器(阿里云和腾讯云)ip比较严重,尽量不要放在服务器里面
- 目前12306对服务器ip比较敏感,大家还是在自己家里挂着吧
- 如果想使用此项目的gui版本,请加群,目前只有mac版本
-
感谢一下小伙伴对本项目提供的帮助
-
@sun7127@126.com
-
@ 才
...
...
config/configCommon.py
浏览文件 @
2f071287
# -*- coding: utf-8 -*-
import
datetime
import
os
import
random
import
sys
import
time
...
...
@@ -102,9 +103,9 @@ def getCacheFile(cacheType):
def
checkSleepTime
(
session
):
now
=
datetime
.
datetime
.
now
()
if
now
.
hour
>=
23
or
now
.
hour
<
6
:
print
(
u
"12306休息时间,本程序自动停止,明天早上
七
点将自动运行"
)
print
(
u
"12306休息时间,本程序自动停止,明天早上
六点
点将自动运行"
)
open_time
=
datetime
.
datetime
(
now
.
year
,
now
.
month
,
now
.
day
,
6
)
if
open_time
<
now
:
open_time
+=
datetime
.
timedelta
(
1
)
time
.
sleep
((
open_time
-
now
).
seconds
)
time
.
sleep
((
open_time
-
now
).
seconds
+
round
(
random
.
uniform
(
1
,
10
))
)
session
.
call_login
()
config/ticket_config.yaml
浏览文件 @
2f071287
...
...
@@ -5,7 +5,8 @@ set:
# - 2018-01-06
# - 2018-01-07
station_dates
:
-
"
2019-02-02"
-
"
2019-02-10"
-
"
2019-02-11"
# 是否根据时间范围 和 乘车类型 购票
# 否则将需要手动填写车次
...
...
@@ -30,15 +31,15 @@ set:
# - "G1353"
# - "G1329"
station_trains
:
-
"
G61
72
"
-
"
G618
6
"
-
"
G61
54
"
-
"
G61
53
"
-
"
G618
4
"
-
"
G61
73
"
# 出发城市,比如深圳北,就填深圳就搜得到
from_station
:
"
广州南
"
from_station
:
"
邵阳
"
# 到达城市 比如深圳北,就填深圳就搜得到
to_station
:
"
邵阳
"
to_station
:
"
深圳北
"
# 座位(list) 多个座位ex:
# - "商务座"
...
...
@@ -54,18 +55,18 @@ set:
-
"
二等座"
# 当余票小于乘车人,如果选择优先提交,则删减联系人和余票数一致在提交
is_more_ticket
:
Tru
e
is_more_ticket
:
Fals
e
# 乘车人(list) 多个乘车人ex:
# - "张三"
# - "李四"
ticke_peoples
:
-
"
文贤平
"
-
"
李梦云
"
# - "梁敏"
-
"
"
-
"
"
# 12306登录账号(list)
12306account
:
-
user
:
"
13828728396
"
-
user
:
"
931128603@qq.com
"
-
pwd
:
"
"
# 加入小黑屋时间默认为5分钟,此功能为了防止僵尸票导致一直下单不成功错过正常的票,
...
...
@@ -106,7 +107,7 @@ email_conf:
# 是否开启cdn查询,可以更快的检测票票 1为开启,2为关闭
is_cdn
:
1
# 下单接口分为两种,1
为快速下单,2 是普通下单
# 下单接口分为两种,1
模拟网页自动捡漏下单(不稳定),2 模拟车次后面的购票按钮下单(稳如老狗)
order_type
:
2
# 下单模式 1 为预售,整点刷新,刷新间隔0.1-0.5S, 然后会校验时间,比如12点的预售,那脚本就会在12.00整检票,刷新订单
...
...
init/select_ticket_info.py
浏览文件 @
2f071287
...
...
@@ -291,14 +291,19 @@ class select:
time
.
sleep
(
random_time
)
except
PassengerUserException
as
e
:
print
(
e
)
break
except
ticketConfigException
as
e
:
print
(
e
)
break
except
ticketIsExitsException
as
e
:
print
(
e
)
break
except
ticketNumOutException
as
e
:
print
(
e
)
break
except
UserPasswordException
as
e
:
print
(
e
)
break
except
ValueError
as
e
:
if
e
==
"No JSON object could be decoded"
:
print
(
u
"12306接口无响应,正在重试"
)
...
...
inter/Query.py
浏览文件 @
2f071287
...
...
@@ -95,7 +95,7 @@ class query:
continue
value
=
station_ticket
.
get
(
"data"
,
""
)
if
not
value
:
print
(
u
'{0}-{1} 车次坐席查询为空,ip网络异常,查询url: https://kyfw.12306.cn{2}, 可以手动查询是否有票'
.
format
(
self
.
from_station_h
,
print
(
u
'{0}-{1} 车次坐席查询为空,ip网络异常,查询url: https://kyfw.12306.cn{2}, 可以手动查询是否有票'
.
format
(
self
.
from_station_h
,
self
.
to_station_h
,
select_url
[
"req_url"
]))
else
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录