Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
janlyn06
12306
提交
bd1a0fca
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 搜索 >>
提交
bd1a0fca
编写于
1月 29, 2018
作者:
W
wenxianping
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1、增加cdn轮训功能
2、兼容Windows cmd命令乱码问题 3、规范接口提交参数 4、修改已知bug
上级
004b8283
变更
8
展开全部
显示空白变更内容
内联
并排
Showing
8 changed file
with
1047 addition
and
734 deletion
+1047
-734
agency/cdn_utils.py
agency/cdn_utils.py
+11
-19
cdn_list
cdn_list
+891
-587
config/ticket_config.yaml
config/ticket_config.yaml
+9
-20
config/urlConf.py
config/urlConf.py
+26
-26
init/login.py
init/login.py
+17
-16
init/select_ticket_info.py
init/select_ticket_info.py
+91
-63
myUrllib/httpUtils.py
myUrllib/httpUtils.py
+2
-3
tkcode
tkcode
+0
-0
未找到文件。
agency/cdn_utils.py
浏览文件 @
bd1a0fca
# encoding=utf8
# encoding=utf8
import
collections
import
collections
import
datetime
import
json
import
json
import
re
import
re
import
sys
import
sys
import
csv
import
requests
import
requests
from
config
import
urlConf
from
config
import
urlConf
from
myUrllib.httpUtils
import
HTTPClient
reload
(
sys
)
reload
(
sys
)
sys
.
setdefaultencoding
(
'utf-8'
)
sys
.
setdefaultencoding
(
'utf-8'
)
...
@@ -88,7 +84,7 @@ class CDNProxy:
...
@@ -88,7 +84,7 @@ class CDNProxy:
num
+=
1
num
+=
1
except
Exception
as
e
:
except
Exception
as
e
:
print
(
e
.
message
)
print
(
e
.
message
)
print
(
"本次cdn获取完成,总个数{0}"
.
format
(
num
))
print
(
u
"本次cdn获取完成,总个数{0}"
.
format
(
num
))
def
all_cdn
(
self
):
def
all_cdn
(
self
):
"""获取cdn列表"""
"""获取cdn列表"""
...
@@ -96,21 +92,17 @@ class CDNProxy:
...
@@ -96,21 +92,17 @@ class CDNProxy:
cdn
=
f
.
readlines
()
cdn
=
f
.
readlines
()
return
cdn
return
cdn
def
cdn_par
(
self
):
def
par_csv
(
self
):
with
open
(
'./cdn_list'
,
'r'
)
as
f
:
cdn_csv
=
csv
.
reader
(
open
(
"../cdn1.csv"
,
"r"
))
cdn
=
f
.
readlines
()
for
c
in
cdn_csv
:
print
cdn
cdn_re
=
re
.
compile
(
r
'https://(\S+)/otn/index/init'
)
for
i
in
cdn
:
cdn_ip
=
re
.
findall
(
cdn_re
,
c
[
0
])
http
=
HTTPClient
()
if
cdn_ip
and
c
[
2
]
==
"200"
:
check_user_url
=
self
.
urlConf
[
"loginInit"
]
print
(
cdn_ip
[
0
])
http
.
cdn
=
i
.
replace
(
"
\n
"
,
""
)
start_time
=
datetime
.
datetime
.
now
()
http
.
send
(
check_user_url
)
print
(
datetime
.
datetime
.
now
()
-
start_time
).
microseconds
/
1000
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
cdn
=
CDNProxy
(
"kyfw.12306.cn"
)
cdn
=
CDNProxy
()
cdn
.
get_city_id
()
cdn
.
get_city_id
()
# cdn.get_cdn_list()
# cdn.get_cdn_list()
cdn
.
cdn_par
()
cdn
.
par_csv
()
cdn_list
浏览文件 @
bd1a0fca
此差异已折叠。
点击以展开。
config/ticket_config.yaml
浏览文件 @
bd1a0fca
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#is_aotu_code是否自动打码,如果选择Ture,则调用打码兔打码,默认不使用打码兔
#is_aotu_code是否自动打码,如果选择Ture,则调用打码兔打码,默认不使用打码兔
#aotu_code_type 1为打码兔,2为若快
#aotu_code_type 1为打码兔,2为若快
#is_email: 是否需要邮件通知 ex: True or False 切记,邮箱加完一定到config目录下测试emailConf功能是否正常
#is_email: 是否需要邮件通知 ex: True or False 切记,邮箱加完一定到config目录下测试emailConf功能是否正常
#is_cdn: 1为需要,2位本机ip查询
#邮箱配置 列举163
#邮箱配置 列举163
# email: "xxx@163.com"
# email: "xxx@163.com"
...
@@ -41,29 +42,17 @@
...
@@ -41,29 +42,17 @@
set
:
set
:
station_dates
:
station_dates
:
# - "2018-01-27"
-
"
2018-02-02"
# - "2018-01-28"
# - "2018-02-22"
-
"
2018-02-24"
station_trains
:
station_trains
:
-
"
D2879
"
-
"
G2366
"
-
"
D1813"
-
"
D1813"
-
"
D2975"
-
"
D2975"
-
"
D1825"
-
"
D1825"
-
"
D1829"
-
"
D1829"
-
"
D2841"
-
"
D2841"
-
"
D1833"
-
"
D1833"
# - "K4300"
from_station
:
"
邵阳"
# - "K5226"
to_station
:
"
上海"
# - "K7772"
# - "G1329"
# - "G1359"
# - "G1361"
# - "G1373"
# - "G1363"
# - "G4933"
from_station
:
"
三江南"
to_station
:
"
广州南"
set_type
:
set_type
:
-
"
一等座"
-
"
一等座"
-
"
二等座"
-
"
二等座"
...
@@ -74,7 +63,7 @@ set:
...
@@ -74,7 +63,7 @@ set:
12306count
:
12306count
:
# - uesr: ""
# - uesr: ""
# - pwd: "apple1995"
# - pwd: "apple1995"
-
uesr
:
"
931128603
@qq.com"
-
uesr
:
"
@qq.com"
-
pwd
:
"
QWERTY"
-
pwd
:
"
QWERTY"
select_refresh_interval
:
0.4
select_refresh_interval
:
0.4
...
@@ -84,14 +73,14 @@ aotu_code_type: 2
...
@@ -84,14 +73,14 @@ aotu_code_type: 2
#enable_proxy: False
#enable_proxy: False
damatu
:
damatu
:
uesr
:
"
931128603
"
uesr
:
"
"
pwd
:
"
qazWSX1995"
pwd
:
"
qazWSX1995"
email_conf
:
email_conf
:
is_email
:
True
is_email
:
True
email
:
"
931128603
@qq.com
"
email
:
"
@qq.com
"
notice_email_list
:
"
61995120@qq.com"
notice_email_list
:
"
61995120@qq.com"
username
:
"
931128603
"
username
:
"
"
password
:
"
xwopwxbkupbqbfgb"
password
:
"
xwopwxbkupbqbfgb"
host
:
"
smtp.qq.com"
host
:
"
smtp.qq.com"
...
...
config/urlConf.py
浏览文件 @
bd1a0fca
...
@@ -6,7 +6,7 @@ urls = {
...
@@ -6,7 +6,7 @@ urls = {
"auth"
:
{
"auth"
:
{
"req_url"
:
"/passport/web/auth/uamtk"
,
"req_url"
:
"/passport/web/auth/uamtk"
,
"req_type"
:
"post"
,
"req_type"
:
"post"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/passport?redirect=/otn/login/userLogin
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
10
,
"re_try"
:
10
,
"re_time"
:
0.1
,
"re_time"
:
0.1
,
...
@@ -16,7 +16,7 @@ urls = {
...
@@ -16,7 +16,7 @@ urls = {
"login"
:
{
"login"
:
{
"req_url"
:
"/passport/web/login"
,
"req_url"
:
"/passport/web/login"
,
"req_type"
:
"post"
,
"req_type"
:
"post"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/login/init
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
10
,
"re_try"
:
10
,
"re_time"
:
0.1
,
"re_time"
:
0.1
,
...
@@ -25,9 +25,9 @@ urls = {
...
@@ -25,9 +25,9 @@ urls = {
},
},
"getCodeImg"
:
{
"getCodeImg"
:
{
"req_url"
:
"/passport/captcha/captcha-image?login_site=E&module=login&rand=sjrand&{0}"
.
format
(
random
.
random
())
,
"req_url"
:
"/passport/captcha/captcha-image?login_site=E&module=login&rand=sjrand&{0}"
,
"req_type"
:
"get"
,
"req_type"
:
"get"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/login/init
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
10
,
"re_try"
:
10
,
"re_time"
:
0.1
,
"re_time"
:
0.1
,
...
@@ -37,7 +37,7 @@ urls = {
...
@@ -37,7 +37,7 @@ urls = {
"codeCheck"
:
{
"codeCheck"
:
{
"req_url"
:
"/passport/captcha/captcha-check"
,
"req_url"
:
"/passport/captcha/captcha-check"
,
"req_type"
:
"post"
,
"req_type"
:
"post"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/login/init
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
10
,
"re_try"
:
10
,
"re_time"
:
0.1
,
"re_time"
:
0.1
,
...
@@ -47,9 +47,9 @@ urls = {
...
@@ -47,9 +47,9 @@ urls = {
"loginInit"
:
{
"loginInit"
:
{
"req_url"
:
"/otn/login/init"
,
"req_url"
:
"/otn/login/init"
,
"req_type"
:
"get"
,
"req_type"
:
"get"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/index/init
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
1
,
"re_try"
:
1
0
,
"re_time"
:
0.1
,
"re_time"
:
0.1
,
"is_logger"
:
False
,
"is_logger"
:
False
,
"is_json"
:
False
,
"is_json"
:
False
,
...
@@ -57,7 +57,7 @@ urls = {
...
@@ -57,7 +57,7 @@ urls = {
"getUserInfo"
:
{
"getUserInfo"
:
{
"req_url"
:
"/otn/index/initMy12306"
,
"req_url"
:
"/otn/index/initMy12306"
,
"req_type"
:
"get"
,
"req_type"
:
"get"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/passport?redirect=/otn/login/userLogin
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
10
,
"re_try"
:
10
,
"re_time"
:
0.1
,
"re_time"
:
0.1
,
...
@@ -67,7 +67,7 @@ urls = {
...
@@ -67,7 +67,7 @@ urls = {
"userLogin"
:
{
"userLogin"
:
{
"req_url"
:
"/otn/login/userLogin"
,
"req_url"
:
"/otn/login/userLogin"
,
"req_type"
:
"get"
,
"req_type"
:
"get"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/passport?redirect=/otn/login/userLogin
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
10
,
"re_try"
:
10
,
"re_time"
:
0.1
,
"re_time"
:
0.1
,
...
@@ -77,7 +77,7 @@ urls = {
...
@@ -77,7 +77,7 @@ urls = {
"uamauthclient"
:
{
"uamauthclient"
:
{
"req_url"
:
"/otn/uamauthclient"
,
"req_url"
:
"/otn/uamauthclient"
,
"req_type"
:
"post"
,
"req_type"
:
"post"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/passport?redirect=/otn/login/userLogin
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
10
,
"re_try"
:
10
,
"re_time"
:
0.1
,
"re_time"
:
0.1
,
...
@@ -87,7 +87,7 @@ urls = {
...
@@ -87,7 +87,7 @@ urls = {
"initdc_url"
:
{
"initdc_url"
:
{
"req_url"
:
"/otn/confirmPassenger/initDc"
,
"req_url"
:
"/otn/confirmPassenger/initDc"
,
"req_type"
:
"get"
,
"req_type"
:
"get"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/leftTicket/init
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
10
,
"re_try"
:
10
,
"re_time"
:
0.1
,
"re_time"
:
0.1
,
...
@@ -97,7 +97,7 @@ urls = {
...
@@ -97,7 +97,7 @@ urls = {
"get_passengerDTOs"
:
{
"get_passengerDTOs"
:
{
"req_url"
:
"/otn/confirmPassenger/getPassengerDTOs"
,
"req_url"
:
"/otn/confirmPassenger/getPassengerDTOs"
,
"req_type"
:
"post"
,
"req_type"
:
"post"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/confirmPassenger/initDc
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
10
,
"re_try"
:
10
,
"re_time"
:
0.1
,
"re_time"
:
0.1
,
...
@@ -107,7 +107,7 @@ urls = {
...
@@ -107,7 +107,7 @@ urls = {
"select_url"
:
{
"select_url"
:
{
"req_url"
:
"/otn/leftTicket/queryZ?leftTicketDTO.train_date={0}&leftTicketDTO.from_station={1}&leftTicketDTO.to_station={2}&purpose_codes=ADULT"
,
"req_url"
:
"/otn/leftTicket/queryZ?leftTicketDTO.train_date={0}&leftTicketDTO.from_station={1}&leftTicketDTO.to_station={2}&purpose_codes=ADULT"
,
"req_type"
:
"post"
,
"req_type"
:
"post"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/leftTicket/init
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
10
,
"re_try"
:
10
,
"re_time"
:
0.1
,
"re_time"
:
0.1
,
...
@@ -117,17 +117,17 @@ urls = {
...
@@ -117,17 +117,17 @@ urls = {
"check_user_url"
:
{
"check_user_url"
:
{
"req_url"
:
"/otn/login/checkUser"
,
"req_url"
:
"/otn/login/checkUser"
,
"req_type"
:
"post"
,
"req_type"
:
"post"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/leftTicket/init
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
1
,
"re_try"
:
1
0
,
"re_time"
:
0.
1
,
"re_time"
:
0.
3
,
"is_logger"
:
True
,
"is_logger"
:
True
,
"is_json"
:
True
,
"is_json"
:
True
,
},
},
"submit_station_url"
:
{
"submit_station_url"
:
{
"req_url"
:
"/otn/leftTicket/submitOrderRequest"
,
"req_url"
:
"/otn/leftTicket/submitOrderRequest"
,
"req_type"
:
"post"
,
"req_type"
:
"post"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/leftTicket/init
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
10
,
"re_try"
:
10
,
"re_time"
:
0.1
,
"re_time"
:
0.1
,
...
@@ -137,7 +137,7 @@ urls = {
...
@@ -137,7 +137,7 @@ urls = {
"checkOrderInfoUrl"
:
{
"checkOrderInfoUrl"
:
{
"req_url"
:
"/otn/confirmPassenger/checkOrderInfo"
,
"req_url"
:
"/otn/confirmPassenger/checkOrderInfo"
,
"req_type"
:
"post"
,
"req_type"
:
"post"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/confirmPassenger/initDc
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
10
,
"re_try"
:
10
,
"re_time"
:
0.1
,
"re_time"
:
0.1
,
...
@@ -147,7 +147,7 @@ urls = {
...
@@ -147,7 +147,7 @@ urls = {
"getQueueCountUrl"
:
{
"getQueueCountUrl"
:
{
"req_url"
:
"/otn/confirmPassenger/getQueueCount"
,
"req_url"
:
"/otn/confirmPassenger/getQueueCount"
,
"req_type"
:
"post"
,
"req_type"
:
"post"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/confirmPassenger/initDc
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
10
,
"re_try"
:
10
,
"re_time"
:
0.1
,
"re_time"
:
0.1
,
...
@@ -157,7 +157,7 @@ urls = {
...
@@ -157,7 +157,7 @@ urls = {
"checkQueueOrderUrl"
:
{
"checkQueueOrderUrl"
:
{
"req_url"
:
"/otn/confirmPassenger/confirmSingleForQueue"
,
"req_url"
:
"/otn/confirmPassenger/confirmSingleForQueue"
,
"req_type"
:
"post"
,
"req_type"
:
"post"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/confirmPassenger/initDc
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
10
,
"re_try"
:
10
,
"re_time"
:
0.1
,
"re_time"
:
0.1
,
...
@@ -167,7 +167,7 @@ urls = {
...
@@ -167,7 +167,7 @@ urls = {
"checkRandCodeAnsyn"
:
{
"checkRandCodeAnsyn"
:
{
"req_url"
:
"/otn/passcodeNew/checkRandCodeAnsyn"
,
"req_url"
:
"/otn/passcodeNew/checkRandCodeAnsyn"
,
"req_type"
:
"post"
,
"req_type"
:
"post"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/confirmPassenger/initDc
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
10
,
"re_try"
:
10
,
"re_time"
:
0.1
,
"re_time"
:
0.1
,
...
@@ -177,7 +177,7 @@ urls = {
...
@@ -177,7 +177,7 @@ urls = {
"codeImgByOrder"
:
{
"codeImgByOrder"
:
{
"req_url"
:
"/otn/passcodeNew/getPassCodeNew?module=passenger&rand=randp&%s"
%
random
.
random
(),
"req_url"
:
"/otn/passcodeNew/getPassCodeNew?module=passenger&rand=randp&%s"
%
random
.
random
(),
"req_type"
:
"post"
,
"req_type"
:
"post"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/confirmPassenger/initDc
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
10
,
"re_try"
:
10
,
"re_time"
:
0.1
,
"re_time"
:
0.1
,
...
@@ -187,7 +187,7 @@ urls = {
...
@@ -187,7 +187,7 @@ urls = {
"queryOrderWaitTimeUrl"
:
{
"queryOrderWaitTimeUrl"
:
{
"req_url"
:
"/otn/confirmPassenger/queryOrderWaitTime"
,
"req_url"
:
"/otn/confirmPassenger/queryOrderWaitTime"
,
"req_type"
:
"post"
,
"req_type"
:
"post"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/confirmPassenger/initDc
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
10
,
"re_try"
:
10
,
"re_time"
:
0.1
,
"re_time"
:
0.1
,
...
@@ -197,7 +197,7 @@ urls = {
...
@@ -197,7 +197,7 @@ urls = {
"queryMyOrderNoCompleteUrl"
:
{
"queryMyOrderNoCompleteUrl"
:
{
"req_url"
:
"/otn/queryOrder/queryMyOrderNoComplete"
,
"req_url"
:
"/otn/queryOrder/queryMyOrderNoComplete"
,
"req_type"
:
"post"
,
"req_type"
:
"post"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/queryOrder/initNoComplete
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
10
,
"re_try"
:
10
,
"re_time"
:
0.1
,
"re_time"
:
0.1
,
...
@@ -207,7 +207,7 @@ urls = {
...
@@ -207,7 +207,7 @@ urls = {
"initNoCompleteUrl"
:
{
"initNoCompleteUrl"
:
{
"req_url"
:
"/otn/queryOrder/initNoComplete"
,
"req_url"
:
"/otn/queryOrder/initNoComplete"
,
"req_type"
:
"post"
,
"req_type"
:
"post"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/queryOrder/initNoComplete
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
10
,
"re_try"
:
10
,
"re_time"
:
0.1
,
"re_time"
:
0.1
,
...
@@ -217,7 +217,7 @@ urls = {
...
@@ -217,7 +217,7 @@ urls = {
"cancelNoCompleteMyOrder"
:
{
"cancelNoCompleteMyOrder"
:
{
"req_url"
:
"/otn/queryOrder/cancelNoCompleteMyOrder"
,
"req_url"
:
"/otn/queryOrder/cancelNoCompleteMyOrder"
,
"req_type"
:
"post"
,
"req_type"
:
"post"
,
"Referer"
:
""
,
"Referer"
:
"
https://kyfw.12306.cn/otn/queryOrder/initNoComplete
"
,
"Host"
:
"kyfw.12306.cn"
,
"Host"
:
"kyfw.12306.cn"
,
"re_try"
:
10
,
"re_try"
:
10
,
"re_time"
:
0.1
,
"re_time"
:
0.1
,
...
...
init/login.py
浏览文件 @
bd1a0fca
...
@@ -24,7 +24,7 @@ class GoLogin:
...
@@ -24,7 +24,7 @@ class GoLogin:
self
.
aotu_code_type
=
aotu_code_type
self
.
aotu_code_type
=
aotu_code_type
def
cookietp
(
self
):
def
cookietp
(
self
):
print
(
"正在获取cookie"
)
print
(
u
"正在获取cookie"
)
url
=
self
.
urlConf
[
"loginInit"
]
url
=
self
.
urlConf
[
"loginInit"
]
self
.
httpClint
.
send
(
url
)
self
.
httpClint
.
send
(
url
)
# Url = "https://kyfw.12306.cn/otn/login/init"
# Url = "https://kyfw.12306.cn/otn/login/init"
...
@@ -67,12 +67,12 @@ class GoLogin:
...
@@ -67,12 +67,12 @@ class GoLogin:
3.控制台输入对应下标,按照英文逗号分开,即可手动完成打码,
3.控制台输入对应下标,按照英文逗号分开,即可手动完成打码,
:return:
:return:
"""
"""
print
(
"下载验证码..."
)
print
(
u
"下载验证码..."
)
codeimgUrl
=
code_url
codeimgUrl
=
code_url
img_path
=
'./tkcode'
img_path
=
'./tkcode'
result
=
self
.
httpClint
.
send
(
codeimgUrl
)
result
=
self
.
httpClint
.
send
(
codeimgUrl
)
try
:
try
:
print
(
"下载验证码成功"
)
print
(
u
"下载验证码成功"
)
open
(
img_path
,
'wb'
).
write
(
result
)
open
(
img_path
,
'wb'
).
write
(
result
)
except
OSError
as
e
:
except
OSError
as
e
:
print
(
e
)
print
(
e
)
...
@@ -83,7 +83,7 @@ class GoLogin:
...
@@ -83,7 +83,7 @@ class GoLogin:
:return: str
:return: str
"""
"""
if
is_raw_input
:
if
is_raw_input
:
Ofset
=
raw_input
(
"请输入验证码: "
)
Ofset
=
raw_input
(
u
"请输入验证码: "
)
select
=
Ofset
.
split
(
','
)
select
=
Ofset
.
split
(
','
)
post
=
[]
post
=
[]
offsetsX
=
0
# 选择的答案的left值,通过浏览器点击8个小图的中点得到的,这样基本没问题
offsetsX
=
0
# 选择的答案的left值,通过浏览器点击8个小图的中点得到的,这样基本没问题
...
@@ -118,7 +118,7 @@ class GoLogin:
...
@@ -118,7 +118,7 @@ class GoLogin:
post
.
append
(
offsetsX
)
post
.
append
(
offsetsX
)
post
.
append
(
offsetsY
)
post
.
append
(
offsetsY
)
randCode
=
str
(
post
).
replace
(
']'
,
''
).
replace
(
'['
,
''
).
replace
(
"'"
,
''
).
replace
(
' '
,
''
)
randCode
=
str
(
post
).
replace
(
']'
,
''
).
replace
(
'['
,
''
).
replace
(
"'"
,
''
).
replace
(
' '
,
''
)
print
(
"验证码识别坐标为{0}"
.
format
(
randCode
))
print
(
u
"验证码识别坐标为{0}"
.
format
(
randCode
))
return
randCode
return
randCode
def
auth
(
self
):
def
auth
(
self
):
...
@@ -141,7 +141,7 @@ class GoLogin:
...
@@ -141,7 +141,7 @@ class GoLogin:
}
}
fresult
=
self
.
httpClint
.
send
(
codeCheck
,
codeCheckData
)
fresult
=
self
.
httpClint
.
send
(
codeCheck
,
codeCheckData
)
if
"result_code"
in
fresult
and
fresult
[
"result_code"
]
==
"4"
:
if
"result_code"
in
fresult
and
fresult
[
"result_code"
]
==
"4"
:
print
(
"验证码通过,开始登录.."
)
print
(
u
"验证码通过,开始登录.."
)
return
True
return
True
else
:
else
:
if
"result_message"
in
fresult
:
if
"result_message"
in
fresult
:
...
@@ -164,7 +164,7 @@ class GoLogin:
...
@@ -164,7 +164,7 @@ class GoLogin:
}
}
tresult
=
self
.
httpClint
.
send
(
logurl
,
logData
)
tresult
=
self
.
httpClint
.
send
(
logurl
,
logData
)
if
'result_code'
in
tresult
and
tresult
[
"result_code"
]
==
0
:
if
'result_code'
in
tresult
and
tresult
[
"result_code"
]
==
0
:
print
(
"登录成功"
)
print
(
u
"登录成功"
)
tk
=
self
.
auth
()
tk
=
self
.
auth
()
if
"newapptk"
in
tk
and
tk
[
"newapptk"
]:
if
"newapptk"
in
tk
and
tk
[
"newapptk"
]:
return
tk
[
"newapptk"
]
return
tk
[
"newapptk"
]
...
@@ -172,11 +172,11 @@ class GoLogin:
...
@@ -172,11 +172,11 @@ class GoLogin:
return
False
return
False
elif
'result_message'
in
tresult
and
tresult
[
'result_message'
]:
elif
'result_message'
in
tresult
and
tresult
[
'result_message'
]:
messages
=
tresult
[
'result_message'
]
messages
=
tresult
[
'result_message'
]
if
messages
.
find
(
"密码输入错误"
)
is
not
-
1
:
if
messages
.
find
(
u
"密码输入错误"
)
is
not
-
1
:
raise
UserPasswordException
(
"{0}"
.
format
(
messages
))
raise
UserPasswordException
(
"{0}"
.
format
(
messages
))
else
:
else
:
print
(
"登录失败: {0}"
.
format
(
messages
))
print
(
u
"登录失败: {0}"
.
format
(
messages
))
print
(
"尝试重新登陆"
)
print
(
u
"尝试重新登陆"
)
return
False
return
False
else
:
else
:
return
False
return
False
...
@@ -187,14 +187,14 @@ class GoLogin:
...
@@ -187,14 +187,14 @@ class GoLogin:
:return:
:return:
"""
"""
if
not
uamtk
:
if
not
uamtk
:
return
"权限校验码不能为空"
return
u
"权限校验码不能为空"
else
:
else
:
uamauthclientUrl
=
self
.
urlConf
[
"uamauthclient"
]
uamauthclientUrl
=
self
.
urlConf
[
"uamauthclient"
]
data
=
{
"tk"
:
uamtk
}
data
=
{
"tk"
:
uamtk
}
uamauthclientResult
=
self
.
httpClint
.
send
(
uamauthclientUrl
,
data
)
uamauthclientResult
=
self
.
httpClint
.
send
(
uamauthclientUrl
,
data
)
if
uamauthclientResult
:
if
uamauthclientResult
:
if
"result_code"
in
uamauthclientResult
and
uamauthclientResult
[
"result_code"
]
==
0
:
if
"result_code"
in
uamauthclientResult
and
uamauthclientResult
[
"result_code"
]
==
0
:
print
(
"欢迎 {} 登录"
.
format
(
uamauthclientResult
[
"username"
]))
print
(
u
"欢迎 {} 登录"
.
format
(
uamauthclientResult
[
"username"
]))
return
True
return
True
else
:
else
:
return
False
return
False
...
@@ -213,14 +213,15 @@ class GoLogin:
...
@@ -213,14 +213,15 @@ class GoLogin:
if
self
.
is_aotu_code
and
self
.
aotu_code_type
==
1
:
if
self
.
is_aotu_code
and
self
.
aotu_code_type
==
1
:
balance
=
DamatuApi
(
_get_yaml
()[
"damatu"
][
"uesr"
],
_get_yaml
()[
"damatu"
][
"pwd"
]).
getBalance
()
balance
=
DamatuApi
(
_get_yaml
()[
"damatu"
][
"uesr"
],
_get_yaml
()[
"damatu"
][
"pwd"
]).
getBalance
()
if
int
(
balance
)
<
40
:
if
int
(
balance
)
<
40
:
raise
balanceException
(
'余额不足,当前余额为: {}'
.
format
(
balance
))
raise
balanceException
(
u
'余额不足,当前余额为: {}'
.
format
(
balance
))
user
,
passwd
=
_get_yaml
()[
"set"
][
"12306count"
][
0
][
"uesr"
],
_get_yaml
()[
"set"
][
"12306count"
][
1
][
"pwd"
]
user
,
passwd
=
_get_yaml
()[
"set"
][
"12306count"
][
0
][
"uesr"
],
_get_yaml
()[
"set"
][
"12306count"
][
1
][
"pwd"
]
if
not
user
or
not
passwd
:
if
not
user
or
not
passwd
:
raise
UserPasswordException
(
"温馨提示: 用户名或者密码为空,请仔细检查"
)
raise
UserPasswordException
(
u
"温馨提示: 用户名或者密码为空,请仔细检查"
)
login_num
=
0
login_num
=
0
while
True
:
while
True
:
self
.
cookietp
()
self
.
cookietp
()
self
.
httpClint
.
set_cookies
(
_jc_save_wfdc_flag
=
"dc"
,
_jc_save_fromStation
=
"%u4E0A%u6D77%u8679%u6865%2CAOH"
,
_jc_save_toStation
=
"%u5170%u5DDE%u897F%2CLAJ"
,
_jc_save_fromDate
=
"2018-02-14"
,
_jc_save_toDate
=
"2018-01-16"
,
RAIL_DEVICEID
=
"EN_3_EGSe2GWGHXJeCkFQ52kHvNCrNlkz9n1GOqqQ1wR0i98WsD8Gj-a3YHZ-XYKeESWgCiJyyucgSwkFOzVHhHqfpidLPcm2vK9n83uzOPuShO3Pl4lCydAtQu4BdFqz-RVmiduNFixrcrN_Ny43135JiEtqLaI"
)
self
.
httpClint
.
set_cookies
(
_jc_save_wfdc_flag
=
"dc"
,
_jc_save_fromStation
=
"%u4E0A%u6D77%u8679%u6865%2CAOH"
,
_jc_save_toStation
=
"%u5170%u5DDE%u897F%2CLAJ"
,
_jc_save_fromDate
=
"2018-02-14"
,
_jc_save_toDate
=
"2018-01-16"
,
RAIL_DEVICEID
=
"EN_3_EGSe2GWGHXJeCkFQ52kHvNCrNlkz9n1GOqqQ1wR0i98WsD8Gj-a3YHZ-XYKeESWgCiJyyucgSwkFOzVHhHqfpidLPcm2vK9n83uzOPuShO3Pl4lCydAtQu4BdFqz-RVmiduNFixrcrN_Ny43135JiEtqLaI"
)
self
.
urlConf
[
"getCodeImg"
][
"req_url"
]
=
self
.
urlConf
[
"getCodeImg"
][
"req_url"
].
format
(
random
.
random
())
self
.
readImg
(
self
.
urlConf
[
"getCodeImg"
])
self
.
readImg
(
self
.
urlConf
[
"getCodeImg"
])
self
.
randCode
=
self
.
getRandCode
()
self
.
randCode
=
self
.
getRandCode
()
login_num
+=
1
login_num
+=
1
...
@@ -235,9 +236,9 @@ class GoLogin:
...
@@ -235,9 +236,9 @@ class GoLogin:
url
=
'https://kyfw.12306.cn/otn/login/loginOut'
url
=
'https://kyfw.12306.cn/otn/login/loginOut'
result
=
myurllib2
.
get
(
url
)
result
=
myurllib2
.
get
(
url
)
if
result
:
if
result
:
print
(
"已退出"
)
print
(
u
"已退出"
)
else
:
else
:
print
(
"退出失败"
)
print
(
u
"退出失败"
)
# if __name__ == "__main__":
# if __name__ == "__main__":
...
...
init/select_ticket_info.py
浏览文件 @
bd1a0fca
此差异已折叠。
点击以展开。
myUrllib/httpUtils.py
浏览文件 @
bd1a0fca
...
@@ -90,7 +90,8 @@ class HTTPClient(object):
...
@@ -90,7 +90,8 @@ class HTTPClient(object):
"""send request to url.If response 200,return response, else return None."""
"""send request to url.If response 200,return response, else return None."""
allow_redirects
=
False
allow_redirects
=
False
is_logger
=
urls
[
"is_logger"
]
is_logger
=
urls
[
"is_logger"
]
error_data
=
{
"code"
:
99999
,
"message"
:
"重试次数达到上限"
}
error_data
=
{
"code"
:
99999
,
"message"
:
u
"重试次数达到上限"
}
self
.
setHeadersReferer
(
urls
[
"Referer"
])
if
data
:
if
data
:
method
=
"post"
method
=
"post"
self
.
setHeaders
({
"Content-Length"
:
"{0}"
.
format
(
len
(
data
))})
self
.
setHeaders
({
"Content-Length"
:
"{0}"
.
format
(
len
(
data
))})
...
@@ -107,7 +108,6 @@ class HTTPClient(object):
...
@@ -107,7 +108,6 @@ class HTTPClient(object):
url_host
=
urls
[
"Host"
]
url_host
=
urls
[
"Host"
]
for
i
in
range
(
urls
[
"re_try"
]):
for
i
in
range
(
urls
[
"re_try"
]):
try
:
try
:
print
(
"https://"
+
url_host
+
urls
[
"req_url"
])
requests
.
packages
.
urllib3
.
disable_warnings
()
requests
.
packages
.
urllib3
.
disable_warnings
()
response
=
self
.
_s
.
request
(
method
=
method
,
response
=
self
.
_s
.
request
(
method
=
method
,
timeout
=
2
,
timeout
=
2
,
...
@@ -116,7 +116,6 @@ class HTTPClient(object):
...
@@ -116,7 +116,6 @@ class HTTPClient(object):
allow_redirects
=
allow_redirects
,
allow_redirects
=
allow_redirects
,
verify
=
False
,
verify
=
False
,
**
kwargs
)
**
kwargs
)
print
(
response
.
status_code
)
if
response
.
status_code
==
200
:
if
response
.
status_code
==
200
:
if
response
.
content
:
if
response
.
content
:
if
is_logger
:
if
is_logger
:
...
...
tkcode
浏览文件 @
bd1a0fca
无法预览此类型文件
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录