diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 6614418..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index a3bd1a8..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index d84fe8e..8aa2a6a 100755 --- a/README.md +++ b/README.md @@ -5,9 +5,11 @@ - [ ] 2.7.9 #### 依赖库 - - 依赖若快 若快注册地址:http://www.ruokuai.com/client/index?6726 推荐用若快,请注册个人账号 + - 验证码目前可以本地识别,需要下载模型,放于项目更目录,全部代码来源于此项目 [传送门](https://github.com/zhaipro/easy12306),表示感谢 ``` - PS: 现在登录有一定几率不用验证码了, + PS: + 1. 模型下载链接:https://pan.baidu.com/s/1rS155VjweWVWIJogakechA 密码:bmlm + 群里面也可以下载 ``` - 项目依赖包查看 requirements.txt - 安装方法-Windows: @@ -64,7 +66,7 @@ - 能为你抢到一张回家的票,是我最大的心愿 #### 日志列子 - - 成功log,如果是购票失败的,请带上失败的log给我,我尽力帮你调,也可加群一起交流,程序只是加速买票的过程,并不一定能买到票 + - 成功log,如果是购票失败的,请带上失败的log给我,我尽力帮你调,也可加群一起交流,程序只是加速买票的过程,并不一定能买到票 ``` 正在第355次查询 乘车日期: 2018-02-12 车次G4741,G2365,G1371,G1377,G1329 查询无票 代理设置 无 总耗时429ms 车次: G4741 始发车站: 上海 终点站: 邵阳 二等座:有 @@ -83,28 +85,32 @@ 恭喜您订票成功,订单号为:EB52743573, 请立即打开浏览器登录12306,访问‘未完成订单’,在30分钟内完成支付! ``` #### 使用帮助(一些安装问题和使用反馈较多的问题): - - 测试邮箱是否可用 [邮箱配置问题看issues](https://github.com/testerSunshine/12306/issues/107) - - 学生票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版本,请加群获取链接 [gui文档](GuiHelp.md) 或者,gui专用群:499098551 + - 测试邮箱是否可用 [邮箱配置问题看issues](https://github.com/testerSunshine/12306/issues/107) + - 学生票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版本,请加群获取链接 [gui文档](GuiHelp.md) 或者,gui专用群:499098551 ``` mac gui and windows gui 下载链接:https://pan.baidu.com/s/1SbVJWxiwP27yb8HUi1kzDQ 密码:41wp ``` - - 自动更换ip软件目前已支持TPLINK和小米路由器,只限家庭网络[点我跳转](https://github.com/testerSunshine/AutoRouterIP) + - 自动更换ip软件目前已支持TPLINK和小米路由器,只限家庭网络[点我跳转](https://github.com/testerSunshine/AutoRouterIP) + - 关于登录接口需要识别DEVICES_ID的情况,可以使用本地打开12306,在任意一接口里面抓取DEVICES_ID,填于login.py文件中的141行 + ``` + 原来的 devicesId = eval(devicesIdRsp.split("(")[1].split(")")[0].replace("'", ""))["dfp"] + 更换为 devicesId = 刚才抓取的DEVICES_ID填上即可 + ``` + - 浏览器截图 + ![image](https://github.com/testerSunshine/12306/blob/master/uml/REIL_DEVICEID.png) + #### 感谢一下小伙伴对本项目提供的帮助 - - @sun7127@126.com - - @ 才 - - @[MonsterTan](https://github.com/MonsterTan) - - 以及所有为此项目提供pr的同学 + - @sun7127@126.com + - @ 才 + - @[MonsterTan](https://github.com/MonsterTan) + - 以及所有为此项目提供pr的同学 #### 更新日志 - - [更新日志](Update.md) - -#### 如果觉得项目还不错,可以考虑打赏一波 -- ![image](https://github.com/testerSunshine/12306/blob/master/uml/zfb.jpeg?imageMogr2/auto-orient/strip) -- ![image](https://github.com/testerSunshine/12306/blob/master/uml/wx.jpeg?imageMogr2/auto-orient/strip) + - [更新日志](Update.md) diff --git a/Update.md b/Update.md index 57d5607..47a1d6a 100644 --- a/Update.md +++ b/Update.md @@ -149,3 +149,6 @@ - 2019.04.23更新 - 修复登录302问题,如果下次没来得及更新,请自行抓包修改urlConf中getDevicesId接口即可登录 + +- 2019.04.23更新 + - 更新本地识别 diff --git a/config/urlConf.py b/config/urlConf.py index d333b86..5e60134 100755 --- a/config/urlConf.py +++ b/config/urlConf.py @@ -139,7 +139,7 @@ urls = { "is_json": False, }, "getDevicesId": { # 获取用户信息 - "req_url": "/otn/HttpZF/logdevice?algID=pKLII3uPX6&hashCode=w0gl_WcMRdpcp8OVHljAtCv2bIz0TUXYjBqPjrXX8og&FMQw=0&q4f3=zh-CN&VySQ=FGGnyDds9R8yEU-K-VRgvF-LXI74dn56&VPIf=1&custID=133&VEek=unknown&dzuS=0&yD16=1&EOQP=c227b88b01f5c513710d4b9f16a5ce52&jp76=69f27b80c0ec8437d2a1f4278674e7fb&hAqN=MacIntel&platform=WEB&ks0Q=e848b8c6800147e416e6663782ca3789&TeRS=831x1440&tOHY=24xx900x1440&Fvje=i1l1o1s1&q5aJ=-8&wNLf=99115dfb07133750ba677d055874de87&0aew=Mozilla/5.0%20(Macintosh;%20Intel%20Mac%20OS%20X%2010_13_4)%20AppleWebKit/605.1.15%20(KHTML,%20like%20Gecko)%20Version/11.1%20Safari/605.1.15&E3gR=a70e835beef705b96a6e51c6ebd50cd4×tamp={0}", + "req_url": "/otn/HttpZF/logdevice?algID=3yxNoRW8BM&hashCode=8EFUGZrjK3cO8VdDugvPxyyiUqMNmKhl6pbW1ftnEVI&FMQw=0&q4f3=zh-CN&VPIf=1&custID=133&VEek=unknown&dzuS=0&yD16=0&EOQP=c227b88b01f5c513710d4b9f16a5ce52&lEnu=2887005765&jp76=52d67b2a5aa5e031084733d5006cc664&hAqN=MacIntel&platform=WEB&ks0Q=d22ca0b81584fbea62237b14bd04c866&TeRS=1013x1920&tOHY=24xx1080x1920&Fvje=i1l1o1s1&q5aJ=-8&wNLf=99115dfb07133750ba677d055874de87&0aew=Mozilla/5.0%20(Macintosh;%20Intel%20Mac%20OS%20X%2010_14_4)%20AppleWebKit/537.36%20(KHTML,%20like%20Gecko)%20Chrome/74.0.3729.131%20Safari/537.36&E3gR=d4c1ccb1725a4a45cc350f16ac26f32b×tamp={0}", "req_type": "get", "Referer": "https://kyfw.12306.cn/otn/passport?redirect=/otn/", "Host": "kyfw.12306.cn", diff --git a/init/login.py b/init/login.py index 22bf439..0a1a743 100755 --- a/init/login.py +++ b/init/login.py @@ -127,17 +127,12 @@ class GoLogin: :param passwd: 密码 :return: """ - # if self.is_auto_code and self.auto_code_type == 1: - # balance = DamatuApi(_get_yaml()["auto_code_account"]["user"], _get_yaml()["auto_code_account"]["pwd"]).getBalance() - # if int(balance) < 40: - # raise balanceException(u'余额不足,当前余额为: {}'.format(balance)) user, passwd = _get_yaml()["set"]["12306account"][0]["user"], _get_yaml()["set"]["12306account"][1]["pwd"] if not user or not passwd: raise UserPasswordException(u"温馨提示: 用户名或者密码为空,请仔细检查") login_num = 0 while True: if loginConf(self.session): - # result = getPassCodeNewOrderAndLogin(session=self.session, imgType="login") self.auth() devicesIdUrl = copy.deepcopy(self.session.urls["getDevicesId"]) @@ -151,6 +146,7 @@ class GoLogin: if not result: continue self.randCode = getRandCode(self.is_auto_code, self.auto_code_type, result) + print(self.randCode) login_num += 1 self.auth() if self.codeCheck(): @@ -161,10 +157,4 @@ class GoLogin: else: loginAysnSuggest(self.session, username=user, password=passwd) login_num += 1 - break - - - -# if __name__ == "__main__": -# # main() -# # logout() \ No newline at end of file + break \ No newline at end of file diff --git a/inter/CheckUser.py b/inter/CheckUser.py index 3b341df..381d779 100644 --- a/inter/CheckUser.py +++ b/inter/CheckUser.py @@ -18,7 +18,7 @@ class checkUser: CHENK_TIME = 0.3 while 1: time.sleep(0.1) # 防止cpu占用过高 - configCommon.checkSleepTime(self.session) # 修复晚上查询线程休眠时,检查登录线程为休眠,造成快豆迅速消耗 + configCommon.checkSleepTime(self.session) # 修复晚上查询线程休眠时,检查登录线程为休眠,造成快豆迅速消耗 if wrapcache.get("user_time") is None: check_user_url = self.session.urls["check_user_url"] data = {"_json_att": ""} @@ -29,10 +29,10 @@ class checkUser: 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'])) + print(ticket.LOGIN_SESSION_FAIL.format(check_user['messages'])) self.session.call_login() wrapcache.set("user_time", datetime.datetime.now(), timeout=60 * CHENK_TIME) else: - print (ticket.LOGIN_SESSION_FAIL.format(check_user['messages'])) + print(ticket.LOGIN_SESSION_FAIL.format(check_user['messages'])) self.session.call_login() - wrapcache.set("user_time", datetime.datetime.now(), timeout=60 * CHENK_TIME) \ No newline at end of file + wrapcache.set("user_time", datetime.datetime.now(), timeout=60 * CHENK_TIME) diff --git a/inter/GetRandCode.py b/inter/GetRandCode.py index a3be94a..b51d4d0 100644 --- a/inter/GetRandCode.py +++ b/inter/GetRandCode.py @@ -2,7 +2,8 @@ from PIL import Image from config.ticketConf import _get_yaml -from damatuCode.ruokuai import RClient +from verify.localVerifyCode import verify +from verify.ruokuai import RClient try: raw_input # Python 2 @@ -21,16 +22,8 @@ def getRandCode(is_auto_code, auto_code_type, result): print(u"打码兔已关闭, 如需使用自动识别,请使用如果平台 auto_code_type == 2") return if auto_code_type == 2: - rc = RClient(_get_yaml()["auto_code_account"]["user"], _get_yaml()["auto_code_account"]["pwd"]) - # im = open('./tkcode', 'rb').read() - # Result = rc.rk_create(result, 6113) - Result = rc.rk_create_base64(result, 6113) - if "Result" in Result: - return codexy(Ofset=",".join(list(Result["Result"])), is_raw_input=False) - else: - if "Error" in Result and Result["Error"]: - print(u"打码平台错误: {0}, 请登录打码平台查看-http://www.ruokuai.com/client/index?6726".format(Result["Error"])) - return "" + Result = verify(result) + return codexy(Ofset=Result, is_raw_input=False) else: img = Image.open('./tkcode.png') img.show() @@ -56,8 +49,11 @@ def codexy(Ofset=None, is_raw_input=True): print(u"如果是linux无图形界面,请使用自动打码,is_auto_code: True") print(u"如果没有弹出验证码,请手动双击根目录下的tkcode.png文件") Ofset = raw_input(u"输入对应的验证码: ") - Ofset = Ofset.replace(",", ",") - select = Ofset.split(',') + if isinstance(Ofset, list): + select = Ofset + else: + Ofset = Ofset.replace(",", ",") + select = Ofset.split(',') post = [] offsetsX = 0 # 选择的答案的left值,通过浏览器点击8个小图的中点得到的,这样基本没问题 offsetsY = 0 # 选择的答案的top值 diff --git a/myUrllib/httpUtils.py b/myUrllib/httpUtils.py index d49bbd2..265f1c7 100755 --- a/myUrllib/httpUtils.py +++ b/myUrllib/httpUtils.py @@ -170,5 +170,4 @@ class HTTPClient(object): pass except socket.error: pass - print(error_data.get("massage")) return error_data diff --git a/requirements.txt b/requirements.txt index 5e12b2e..52439ce 100755 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,4 @@ six==1.10.0 requests==2.18.4 Pillow==5.0.0 wrapcache==1.0.8 -ntplib==0.3.3 \ No newline at end of file +ntplib==0.3.3 diff --git a/tkcode.png b/tkcode.png index 35a70ff..fc07645 100644 Binary files a/tkcode.png and b/tkcode.png differ diff --git a/damatuCode/__init__.py b/verify/__init__.py similarity index 100% rename from damatuCode/__init__.py rename to verify/__init__.py diff --git a/damatuCode/ruokuai.py b/verify/ruokuai.py similarity index 100% rename from damatuCode/ruokuai.py rename to verify/ruokuai.py