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
bc29d8a8
Commit
bc29d8a8
authored
Jan 08, 2019
by
Jalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化输出信息
parent
a0f26435
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
36 deletions
+22
-36
README.md
README.md
+2
-0
OCR.py
py12306/helpers/OCR.py
+11
-29
job.py
py12306/user/job.py
+9
-7
No files found.
README.md
View file @
bc29d8a8
...
@@ -12,8 +12,10 @@
...
@@ -12,8 +12,10 @@
-
[
x
]
电话语音通知
-
[
x
]
电话语音通知
-
[
x
]
多账号、多任务、多线程支持
-
[
x
]
多账号、多任务、多线程支持
-
[
x
]
单个任务多站点查询
-
[
x
]
单个任务多站点查询
-
[
]
分布式运行
-
[
]
Docker 支持
-
[
]
Docker 支持
-
[
]
邮件通知
-
[
]
邮件通知
-
[
]
Web 管理页面
## 使用
## 使用
py12306 需要运行在 python 3.6 以上版本(其它版本暂未测试)
py12306 需要运行在 python 3.6 以上版本(其它版本暂未测试)
...
...
py12306/helpers/OCR.py
View file @
bc29d8a8
import
math
import
random
from
py12306
import
config
from
py12306
import
config
from
py12306.log.common_log
import
CommonLog
from
py12306.log.common_log
import
CommonLog
from
py12306.vender.ruokuai.main
import
RKClient
from
py12306.vender.ruokuai.main
import
RKClient
...
@@ -32,39 +35,18 @@ class OCR:
...
@@ -32,39 +35,18 @@ class OCR:
def
get_image_position_by_offset
(
self
,
offsets
):
def
get_image_position_by_offset
(
self
,
offsets
):
positions
=
[]
positions
=
[]
width
=
70
height
=
70
random_num
=
random
.
randint
(
0
,
10
)
for
offset
in
offsets
:
for
offset
in
offsets
:
if
offset
==
'1'
:
offset
=
int
(
offset
)
y
=
46
x
=
width
*
(
offset
%
5
)
-
width
/
2
+
random_num
x
=
42
y
=
height
*
math
.
ceil
(
offset
/
4
)
-
height
/
2
-
random_num
elif
offset
==
'2'
:
positions
.
append
(
int
(
x
))
y
=
46
positions
.
append
(
int
(
y
))
x
=
105
elif
offset
==
'3'
:
y
=
45
x
=
184
elif
offset
==
'4'
:
y
=
48
x
=
256
elif
offset
==
'5'
:
y
=
36
x
=
117
elif
offset
==
'6'
:
y
=
112
x
=
115
elif
offset
==
'7'
:
y
=
114
x
=
181
elif
offset
==
'8'
:
y
=
111
x
=
252
else
:
pass
positions
.
append
(
x
)
positions
.
append
(
y
)
return
positions
return
positions
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
pass
pass
# code_result = AuthCode.get_auth_code()
# code_result = AuthCode.get_auth_code()
py12306/user/job.py
View file @
bc29d8a8
...
@@ -103,10 +103,10 @@ class UserJob:
...
@@ -103,10 +103,10 @@ class UserJob:
elif
result
.
get
(
'result_code'
)
==
2
:
# 账号之内错误
elif
result
.
get
(
'result_code'
)
==
2
:
# 账号之内错误
# 登录失败,用户名或密码为空
# 登录失败,用户名或密码为空
# 密码输入错误
# 密码输入错误
UserLog
.
add_quick_log
(
UserLog
.
MESSAGE_LOGIN_FAIL
.
format
(
result
.
get
(
'result_message'
)))
UserLog
.
add_quick_log
(
UserLog
.
MESSAGE_LOGIN_FAIL
.
format
(
result
.
get
(
'result_message'
)))
.
flush
()
else
:
else
:
UserLog
.
add_quick_log
(
UserLog
.
add_quick_log
(
UserLog
.
MESSAGE_LOGIN_FAIL
.
format
(
result
.
get
(
'result_message'
,
result
.
get
(
'message'
,
'-'
))))
UserLog
.
MESSAGE_LOGIN_FAIL
.
format
(
result
.
get
(
'result_message'
,
result
.
get
(
'message'
,
'-'
))))
.
flush
()
return
False
return
False
...
@@ -117,6 +117,9 @@ class UserJob:
...
@@ -117,6 +117,9 @@ class UserJob:
is_login
=
response
.
json
()
.
get
(
'data'
)
.
get
(
'flag'
,
False
)
is_login
=
response
.
json
()
.
get
(
'data'
)
.
get
(
'flag'
,
False
)
if
is_login
:
if
is_login
:
self
.
save_user
()
self
.
save_user
()
self
.
get_user_info
()
# 检测应该是不会维持状态,这里再请求下个人中心看有没有有
return
is_login
return
is_login
def
auth_uamtk
(
self
):
def
auth_uamtk
(
self
):
...
@@ -168,12 +171,11 @@ class UserJob:
...
@@ -168,12 +171,11 @@ class UserJob:
:return:
:return:
"""
"""
UserLog
.
add_quick_log
(
UserLog
.
MESSAGE_LOADED_USER
.
format
(
self
.
user_name
))
UserLog
.
add_quick_log
(
UserLog
.
MESSAGE_LOADED_USER
.
format
(
self
.
user_name
))
if
self
.
check_user_is_login
():
if
self
.
check_user_is_login
()
and
self
.
get_user_info
():
UserLog
.
add_quick_log
(
UserLog
.
MESSAGE_LOADED_USER_SUCCESS
.
format
(
self
.
user_name
))
UserLog
.
add_quick_log
(
UserLog
.
MESSAGE_LOADED_USER_SUCCESS
.
format
(
self
.
user_name
))
.
flush
()
self
.
get_user_info
()
UserLog
.
print_welcome_user
(
self
)
UserLog
.
print_welcome_user
(
self
)
else
:
else
:
UserLog
.
add_quick_log
(
UserLog
.
MESSAGE_LOADED_USER_BUT_EXPIRED
)
UserLog
.
add_quick_log
(
UserLog
.
MESSAGE_LOADED_USER_BUT_EXPIRED
)
.
flush
()
def
get_user_info
(
self
):
def
get_user_info
(
self
):
response
=
self
.
session
.
get
(
API_USER_INFO
.
get
(
'url'
))
response
=
self
.
session
.
get
(
API_USER_INFO
.
get
(
'url'
))
...
@@ -205,7 +207,7 @@ class UserJob:
...
@@ -205,7 +207,7 @@ class UserJob:
return
self
.
passengers
return
self
.
passengers
else
:
else
:
UserLog
.
add_quick_log
(
UserLog
.
add_quick_log
(
UserLog
.
MESSAGE_GET_USER_PASSENGERS_FAIL
.
format
(
result
.
get
(
'messages'
,
'-'
),
self
.
retry_time
))
UserLog
.
MESSAGE_GET_USER_PASSENGERS_FAIL
.
format
(
result
.
get
(
'messages'
,
'-'
),
self
.
retry_time
))
.
flush
()
stay_second
(
self
.
retry_time
)
stay_second
(
self
.
retry_time
)
return
self
.
get_user_passengers
()
return
self
.
get_user_passengers
()
...
...
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