Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
janlyn06
12306
提交
7a26f844
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 搜索 >>
提交
7a26f844
编写于
9月 07, 2019
作者:
X
xianping.wen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化候补逻辑
上级
4f7d9807
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
37 addition
and
32 deletion
+37
-32
TickerConfig.py
TickerConfig.py
+10
-9
Update.md
Update.md
+4
-0
config/configCommon.py
config/configCommon.py
+1
-1
init/select_ticket_info.py
init/select_ticket_info.py
+2
-2
inter/ChechFace.py
inter/ChechFace.py
+6
-1
inter/CheckUser.py
inter/CheckUser.py
+1
-1
inter/Query.py
inter/Query.py
+13
-18
未找到文件。
TickerConfig.py
浏览文件 @
7a26f844
...
...
@@ -13,8 +13,9 @@ TICKET_TYPE = 2
J_Z_PARAM
=
"2019-09-28#22#59"
# 出发日期(list) "2018-01-06", "2018-01-07"
# ps: 日期如果是单日,一定要前面补个0,正确做法:2019-01-01, 错误做法:2019-1-1
STATION_DATES
=
[
"2019-
10-01
"
"2019-
09-25
"
]
# 填入需要购买的车次(list),"G1353"
...
...
@@ -23,10 +24,10 @@ STATION_TRAINS = [
]
# 出发城市,比如深圳北,就填深圳就搜得到
FROM_STATION
=
"
深圳北
"
FROM_STATION
=
""
# 到达城市 比如深圳北,就填深圳就搜得到
TO_STATION
=
"
隆回
"
TO_STATION
=
""
# 座位(list) 多个座位ex:
# "商务座",
...
...
@@ -39,7 +40,7 @@ TO_STATION = "隆回"
# "无座",
# "动卧",
SET_TYPE
=
[
"
二等座
"
,
""
,
]
# 当余票小于乘车人,如果选择优先提交,则删减联系人和余票数一致在提交
...
...
@@ -77,7 +78,7 @@ IS_AUTO_CODE = True
# password: "授权码"
# host: "smtp.qq.com"
EMAIL_CONF
=
{
"IS_MAIL"
:
Tru
e
,
"IS_MAIL"
:
Fals
e
,
"email"
:
""
,
"notice_email_list"
:
""
,
"username"
:
""
,
...
...
@@ -111,13 +112,13 @@ IS_PROXY = 0
# 预售放票时间, 如果是捡漏模式,可以忽略此操作
OPEN_TIME
=
"13:00:00"
# 1=使用selenium获取devicesID
# 2=使用网页端/otn/HttpZF/logdevice获取devicesId,这个接口的算法目前可能有点问题,如果登录一直302的请改为配置1
COOKIE_TYPE
=
1
# 如果COOKIE_TYPE=1,则需配置chromeDriver路径,下载地址http://chromedriver.storage.googleapis.com/index.html
# 如果COOKIE_TYPE=1,则需配置chromeDriver路径
(注意是填你机器本地chromeDriver的路径,这个地方一定要改)
,下载地址http://chromedriver.storage.googleapis.com/index.html
# chromedriver配置版本只要和chrome的大版本匹配就行
CHROME_PATH
=
"/Users/wenxianping/Downloads/chromedriver"
# 如果是windows,最好在路径加上r, ex: r"/Users/wenxianping/Downloads/chromedriver"
CHROME_PATH
=
""
PASSENGER_TICKER_STR
=
{
'一等座'
:
'M'
,
...
...
@@ -132,4 +133,4 @@ PASSENGER_TICKER_STR = {
}
# 软件版本
RE_VERSION
=
"1.1.10
5
"
RE_VERSION
=
"1.1.10
6
"
Update.md
浏览文件 @
7a26f844
...
...
@@ -173,3 +173,7 @@
-
恢复TICKET_TYPE字段,1=刷票 2=候补+刷票
-
优化候补逻辑
-
候补订单只能在规定车次内候补
-
2019.09.07更新
-
优化候补逻辑
-
去除敏感信息打印
config/configCommon.py
浏览文件 @
7a26f844
...
...
@@ -107,7 +107,7 @@ def checkSleepTime(session):
now
=
datetime
.
datetime
.
now
()
if
now
.
hour
>=
maxRunStopTime
or
now
.
hour
<
maxRunTime
:
print
(
u
"12306休息时间,本程序自动停止,明天早上六点将自动运行"
)
open_time
=
datetime
.
datetime
(
now
.
year
,
now
.
month
,
now
.
day
,
6
)
open_time
=
datetime
.
datetime
(
now
.
year
,
now
.
month
,
now
.
day
,
maxRunTime
)
if
open_time
<
now
:
open_time
+=
datetime
.
timedelta
(
1
)
time
.
sleep
((
open_time
-
now
).
seconds
+
round
(
random
.
uniform
(
1
,
10
)))
...
...
init/select_ticket_info.py
浏览文件 @
7a26f844
...
...
@@ -57,7 +57,7 @@ class select:
print
(
u
"*"
*
50
)
print
(
f
"检查当前版本为:
{
TickerConfig
.
RE_VERSION
}
"
)
print
(
u
"检查当前python版本为:{},目前版本只支持3.6以上"
.
format
(
sys
.
version
.
split
(
" "
)[
0
]))
print
(
u
"12306刷票小助手,最后更新于2019.09.0
3
,请勿作为商业用途,交流群号:"
print
(
u
"12306刷票小助手,最后更新于2019.09.0
7
,请勿作为商业用途,交流群号:"
u
" 1群:286271084(已满)
\n
"
u
" 2群:649992274(已满)
\n
"
u
" 3群:632501142(已满)
\n
"
...
...
@@ -235,7 +235,7 @@ class select:
TickerConfig
.
TICKET_PEOPLES
)
sor
.
sendSubmitOrderRequest
()
elif
secretList
:
# 候补订单
c
=
chechFace
(
self
,
secretList
)
c
=
chechFace
(
self
,
secretList
,
train_no
)
c
.
sendChechFace
()
else
:
random_time
=
round
(
random
.
uniform
(
sleep_time_s
,
sleep_time_t
),
2
)
...
...
inter/ChechFace.py
浏览文件 @
7a26f844
import
datetime
import
urllib
from
collections
import
OrderedDict
from
config.urlConf
import
urls
import
TickerConfig
from
inter.GetSuccessRate
import
getSuccessRate
from
myException.ticketConfigException
import
ticketConfigException
import
wrapcache
class
chechFace
:
def
__init__
(
self
,
session
,
secretList
):
def
__init__
(
self
,
session
,
secretList
,
train_no
):
"""
人脸识别
"""
self
.
secretList
=
secretList
self
.
session
=
session
self
.
train_no
=
train_no
def
data_apr
(
self
):
"""
...
...
@@ -31,6 +34,8 @@ class chechFace:
chechFaceRsp
=
self
.
session
.
httpClint
.
send
(
urls
.
get
(
"chechFace"
),
self
.
data_apr
())
if
not
chechFaceRsp
.
get
(
"status"
):
print
(
""
.
join
(
chechFaceRsp
.
get
(
"messages"
))
or
chechFaceRsp
.
get
(
"validateMessages"
))
wrapcache
.
set
(
key
=
f
"hb
{
self
.
train_no
}
"
,
value
=
datetime
.
datetime
.
now
(),
timeout
=
TickerConfig
.
TICKET_BLACK_LIST_TIME
*
60
)
return
data
=
chechFaceRsp
[
"data"
]
if
not
data
.
get
(
"face_flag"
):
...
...
inter/CheckUser.py
浏览文件 @
7a26f844
...
...
@@ -26,7 +26,7 @@ class checkUser:
if
check_user
.
get
(
"data"
,
False
):
check_user_flag
=
check_user
[
"data"
][
"flag"
]
if
check_user_flag
is
True
:
wrapcache
.
set
(
"user_time"
,
datetime
.
datetime
.
now
(),
timeout
=
60
*
CHENK_TIME
)
wrapcache
.
set
(
"user_time"
,
datetime
.
datetime
.
now
(),
timeout
=
60
*
CHENK_TIME
)
else
:
if
check_user
[
'messages'
]:
print
(
ticket
.
LOGIN_SESSION_FAIL
.
format
(
check_user
[
'messages'
]))
...
...
inter/Query.py
浏览文件 @
7a26f844
...
...
@@ -49,18 +49,6 @@ class query:
def
check_is_need_train
(
self
,
ticket_info
):
return
ticket_info
[
3
]
in
self
.
station_trains
# def sendQueryFirst(self):
# """
# 首次请求打印接口车次信息
# :return:
# """
# for station_date in self.station_dates:
# select_url = copy.copy(self.urls["select_url"])
# select_url["req_url"] = select_url["req_url"].format(station_date, self.from_station, self.to_station,
# self.session.queryUrl)
# station_ticket = self.httpClint.send(select_url)
# values = station_ticket.get("data", "")
def
sendQuery
(
self
):
"""
查询
...
...
@@ -74,10 +62,6 @@ class query:
select_url
[
"req_url"
]
=
select_url
[
"req_url"
].
format
(
station_date
,
self
.
from_station
,
self
.
to_station
,
self
.
session
.
queryUrl
)
station_ticket
=
self
.
httpClint
.
send
(
select_url
)
# if station_ticket.get("c_url", ""):
# print(u"设置当前查询url为: {}".format(station_ticket.get("c_url", "")))
# self.session.queryUrl = station_ticket.get("c_url", "") # 重设查询接口
# continue
value
=
station_ticket
.
get
(
"data"
,
""
)
if
not
value
:
print
(
u
'{0}-{1} 车次坐席查询为空,查询url: https://kyfw.12306.cn{2}, 可以手动查询是否有票'
.
format
(
...
...
@@ -90,7 +74,16 @@ class query:
for
i
in
value
[
'result'
]:
ticket_info
=
i
.
split
(
'|'
)
if
self
.
session
.
flag
:
print
(
f
"车次:
{
ticket_info
[
3
]
}
出发站:
{
self
.
from_station_h
}
到达站:
{
self
.
to_station_h
}
历时:
{
ticket_info
[
10
]
}
商务/特等座:
{
ticket_info
[
32
]
}
一等座:
{
ticket_info
[
31
]
}
二等座:
{
ticket_info
[
30
]
}
动卧:
{
ticket_info
[
33
]
}
硬卧:
{
ticket_info
[
28
]
}
软座:
{
ticket_info
[
23
]
}
硬座:
{
ticket_info
[
29
]
}
无座:
{
ticket_info
[
26
]
}
{
ticket_info
[
1
]
}
"
)
print
(
f
"车次:
{
ticket_info
[
3
]
}
出发站:
{
self
.
from_station_h
}
到达站:
{
self
.
to_station_h
}
历时:
{
ticket_info
[
10
]
}
"
f
" 商务/特等座:
{
ticket_info
[
32
]
or
'--'
}
"
f
" 一等座:
{
ticket_info
[
31
]
or
'--'
}
"
f
" 二等座:
{
ticket_info
[
30
]
or
'--'
}
"
f
" 动卧:
{
ticket_info
[
33
]
or
'--'
}
"
f
" 硬卧:
{
ticket_info
[
28
]
or
'--'
}
"
f
" 软座:
{
ticket_info
[
23
]
or
'--'
}
"
f
" 硬座:
{
ticket_info
[
29
]
or
'--'
}
"
f
" 无座:
{
ticket_info
[
26
]
or
'--'
}
"
f
"
{
ticket_info
[
1
]
or
'--'
}
"
)
if
ticket_info
[
1
]
==
"预订"
and
self
.
check_is_need_train
(
ticket_info
):
# 筛选未在开始时间内的车次
for
j
in
self
.
_station_seat
:
is_ticket_pass
=
ticket_info
[
j
]
...
...
@@ -156,12 +149,14 @@ class query:
"""
# 如果最后一位为1,则是可以候补的,不知道这些正确嘛?
nate
=
list
(
ticket_info
[
-
1
])
if
wrapcache
.
get
(
f
"hb
{
ticket_info
[
2
]
}
"
):
continue
for
set_type
in
TickerConfig
.
SET_TYPE
:
if
TickerConfig
.
PASSENGER_TICKER_STR
[
set_type
]
not
in
nate
:
print
(
f
"当前订单可以候补,候补位置为:
{
set_type
}
, 尝试提交候补订单"
)
return
{
"secretList"
:
ticket_info
[
0
],
"seat"
:
[
set_type
],
"train_no"
:
ticket_info
[
2
],
"status"
:
True
,
}
else
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录