Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
py12306
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
python
py12306
Commits
a0f26435
Commit
a0f26435
authored
Jan 08, 2019
by
Jalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加单个任务添加多个出发和到达车站
parent
054c476c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
16 deletions
+38
-16
README.md
README.md
+3
-3
env.py.example
env.py.example
+9
-1
query_log.py
py12306/log/query_log.py
+3
-1
job.py
py12306/query/job.py
+23
-11
No files found.
README.md
View file @
a0f26435
# 🚂 py12306 购票助手
多账号,多任务购票
支持
多账号,多任务购票
## 前言
今年回家的票明显要难买很多,早早就答应了父母今年的票没问题,到现在一张票没买到,虽然家里已经订了汽车票,让我不用操心,但是想想他们一行还有小孩,心还是很伤的。
...
...
@@ -11,7 +11,7 @@
-
[
x
]
用户状态恢复
-
[
x
]
电话语音通知
-
[
x
]
多账号、多任务、多线程支持
-
[
]
单个任务多站点查询
-
[
x
]
单个任务多站点查询
-
[
]
Docker 支持
-
[
]
邮件通知
...
...
@@ -57,7 +57,7 @@ python main.py -t -n
python main.py
```
## 下单成功
图片
## 下单成功
截图

## Thanks
...
...
env.py.example
View file @
a0f26435
...
...
@@ -52,10 +52,18 @@ QUERY_JOBS = [
"2019-01-25",
"2019-01-26",
],
'stations': { # 车站
:Dic
t
'stations': { # 车站
支持多个车站同时查询 :Dict or :Lis
t
'left': '北京',
'arrive': '深圳',
},
# # 多个车站示例 (建议添加多个,有时多买几站成功率会高一点)
# 'stations': [{
# 'left': '北京',
# 'arrive': '深圳',
# },{ # 多个车站示例
# 'left': '北京',
# 'arrive': '广州',
# }],
'members': [ # 乘客姓名,会根据当前账号自动识别乘客类型 购买儿童票 设置两个相同的姓名即可,程序会自动识别 如 ['张三', '张三']
"张三",
"王五",
...
...
py12306/log/query_log.py
View file @
a0f26435
...
...
@@ -52,7 +52,9 @@ class QueryLog(BaseLog):
index
=
1
for
job
in
jobs
:
self
.
add_log
(
'================== 任务 {} =================='
.
format
(
index
))
self
.
add_log
(
'出发站:{} 到达站:{}'
.
format
(
job
.
left_station
,
job
.
arrive_station
))
for
station
in
job
.
stations
:
self
.
add_log
(
'出发站:{} 到达站:{}'
.
format
(
station
.
get
(
'left'
),
station
.
get
(
'arrive'
)))
self
.
add_log
(
'乘车日期:{}'
.
format
(
job
.
left_dates
))
self
.
add_log
(
'坐席:{}'
.
format
(
','
.
join
(
job
.
allow_seats
)))
self
.
add_log
(
'乘车人:{}'
.
format
(
','
.
join
(
job
.
members
)))
...
...
py12306/query/job.py
View file @
a0f26435
...
...
@@ -14,6 +14,7 @@ class Job:
left_dates
=
[]
left_date
=
None
stations
=
[]
left_station
=
''
arrive_station
=
''
left_station_code
=
''
...
...
@@ -45,10 +46,13 @@ class Job:
def
__init__
(
self
,
info
,
query
):
self
.
left_dates
=
info
.
get
(
'left_dates'
)
self
.
left_station
=
info
.
get
(
'stations'
)
.
get
(
'left'
)
self
.
arrive_station
=
info
.
get
(
'stations'
)
.
get
(
'arrive'
)
self
.
left_station_code
=
Station
.
get_station_key_by_name
(
self
.
left_station
)
self
.
arrive_station_code
=
Station
.
get_station_key_by_name
(
self
.
arrive_station
)
# 多车站已放在下面处理
# self.left_station = info.get('stations').get('left')
# self.arrive_station = info.get('stations').get('arrive')
# self.left_station_code = Station.get_station_key_by_name(self.left_station)
# self.arrive_station_code = Station.get_station_key_by_name(self.arrive_station)
self
.
stations
=
info
.
get
(
'stations'
)
self
.
stations
=
[
self
.
stations
]
if
isinstance
(
self
.
stations
,
dict
)
else
self
.
stations
self
.
account_key
=
info
.
get
(
'account_key'
)
self
.
allow_seats
=
info
.
get
(
'seats'
)
...
...
@@ -74,13 +78,15 @@ class Job:
:return:
"""
QueryLog
.
print_job_start
()
for
date
in
self
.
left_dates
:
self
.
left_date
=
date
response
=
self
.
query_by_date
(
date
)
self
.
handle_response
(
response
)
self
.
safe_stay
()
if
is_main_thread
():
QueryLog
.
flush
(
sep
=
'
\t\t
'
)
for
station
in
self
.
stations
:
self
.
refresh_station
(
station
)
for
date
in
self
.
left_dates
:
self
.
left_date
=
date
response
=
self
.
query_by_date
(
date
)
self
.
handle_response
(
response
)
self
.
safe_stay
()
if
is_main_thread
():
QueryLog
.
flush
(
sep
=
'
\t\t
'
)
if
is_main_thread
():
QueryLog
.
add_quick_log
(
''
)
.
flush
()
else
:
...
...
@@ -201,6 +207,12 @@ class Job:
User
.
check_members
(
self
.
members
,
self
.
account_key
,
call_back
=
self
.
set_passengers
)
return
True
def
refresh_station
(
self
,
station
):
self
.
left_station
=
station
.
get
(
'left'
)
self
.
arrive_station
=
station
.
get
(
'arrive'
)
self
.
left_station_code
=
Station
.
get_station_key_by_name
(
self
.
left_station
)
self
.
arrive_station_code
=
Station
.
get_station_key_by_name
(
self
.
arrive_station
)
# 提供一些便利方法
def
get_info_of_left_date
(
self
):
return
self
.
ticket_info
[
self
.
INDEX_LEFT_DATE
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment