From 5fd9b8f8c9915e1b09eef414028886b14f431b05 Mon Sep 17 00:00:00 2001 From: "xianping.wen" <931128603@qq.com> Date: Wed, 18 Sep 2019 09:52:55 +0800 Subject: [PATCH] update version 1.1.114 --- TickerConfig.py | 41 +++++++++++++++++++++----------------- Update.md | 4 ++++ config/urlConf.py | 14 +++++++++++-- init/select_ticket_info.py | 14 ++++++++----- inter/GetRandCode.py | 10 +++++++++- inter/Query.py | 4 ++-- myUrllib/httpUtils.py | 4 ++-- verify/localVerifyCode.py | 18 ++++++++--------- verify/mlearn_for_image.py | 20 ++++++++++--------- verify/pretreatment.py | 18 +++++++++-------- 10 files changed, 91 insertions(+), 56 deletions(-) diff --git a/TickerConfig.py b/TickerConfig.py index f4a0262..7614dbc 100644 --- a/TickerConfig.py +++ b/TickerConfig.py @@ -4,24 +4,23 @@ # 如果这个时候捡漏捡到的话,也是可以付款成功的,也就是说,捡漏+候补,可以最大程度提升抢票成功率 # 刷票模式:1=刷票 2=候补+刷票 -TICKET_TYPE = 2 +TICKET_TYPE = 1 # 出发日期(list) "2018-01-06", "2018-01-07" STATION_DATES = [ - "2019-10-01" + "2019-09-26" ] # 填入需要购买的车次(list),"G1353" # 修改车次填入规则,注:(以前设置的车次逻辑不变),如果车次填入为空,那么就是当日乘车所有车次都纳入筛选返回 -STATION_TRAINS = [ - "", -] +# 不填车次是整个list为空才算,如果不是为空,依然会判断车次的,这种是错误的写法 [""], 正确的写法 [] +STATION_TRAINS = [] # 出发城市,比如深圳北,就填深圳就搜得到 -FROM_STATION = "" +FROM_STATION = "松山湖北" # 到达城市 比如深圳北,就填深圳就搜得到 -TO_STATION = "" +TO_STATION = "西平西" # 座位(list) 多个座位ex: # "商务座", @@ -34,7 +33,7 @@ TO_STATION = "" # "无座", # "动卧", SET_TYPE = [ - "", + "无座", ] # 当余票小于乘车人,如果选择优先提交,则删减联系人和余票数一致在提交 @@ -45,12 +44,13 @@ IS_MORE_TICKET = True # - "张三" # - "李四" TICKET_PEOPLES = [ - "", + "文贤平", + "李梦云", ] # 12306登录账号 -USER = "" -PWD = "" +USER = "qqxin1011" +PWD = "quxm19861011" # 加入小黑屋时间默认为5分钟,此功能为了防止僵尸票导致一直下单不成功错过正常的票 TICKET_BLACK_LIST_TIME = 5 @@ -58,6 +58,10 @@ TICKET_BLACK_LIST_TIME = 5 # 自动打码 IS_AUTO_CODE = True +# 设置2本地自动打码,需要配置tensorflow和keras库,3为云打码,由于云打码服务器资源有限(为2h4C的cpu服务器),请不要恶意请求,不然只能关闭服务器 +# ps: 请不要一直依赖云服务器资源,在此向提供服务器的"do it"同学表示感谢 +AUTO_CODE_TYPE = 2 + # 邮箱配置,如果抢票成功,将通过邮件配置通知给您 # 列举163 # email: "xxx@163.com" @@ -73,11 +77,11 @@ IS_AUTO_CODE = True # host: "smtp.qq.com" EMAIL_CONF = { "IS_MAIL": True, - "email": "", - "notice_email_list": "", - "username": "", - "password": "", - "host": "", + "email": "931128603@qq.com", + "notice_email_list": "931128603@qq.com", + "username": "931128603@qq.com", + "password": "lwvgfrcydzyvbfjf", + "host": "smtp.qq.com", } # 是否开启 server酱 微信提醒, 使用前需要前往 http://sc.ftqq.com/3.version 扫码绑定获取 SECRET 并关注获得抢票结果通知的公众号 @@ -111,7 +115,7 @@ OPEN_TIME = "13:00:00" COOKIE_TYPE = 1 # 如果COOKIE_TYPE=1,则需配置chromeDriver路径,下载地址http://chromedriver.storage.googleapis.com/index.html # chromedriver配置版本只要和chrome的大版本匹配就行 -CHROME_PATH = "" +CHROME_PATH = "/Users/wenxianping/Downloads/chromedriver" # 1=>为一直随机ua,2->只启动的时候随机一次ua RANDOM_AGENT = 2 @@ -133,5 +137,6 @@ PASSENGER_TICKER_STR = { MAX_TIME = 5 # 最小间隔请求时间 MIN_TIME = 3 + # 软件版本 -RE_VERSION = "1.1.113" +RE_VERSION = "1.1.114" \ No newline at end of file diff --git a/Update.md b/Update.md index 44ad553..cc5c979 100644 --- a/Update.md +++ b/Update.md @@ -185,3 +185,7 @@ - 增长随机停留时长 - 增长用户心跳时间,减少对服务器压力 - 优化下单逻辑 + +- 2019.09.18更新 + - 修改下单问题 + - 优化车次打印 \ No newline at end of file diff --git a/config/urlConf.py b/config/urlConf.py index 4cf9203..00d54f2 100755 --- a/config/urlConf.py +++ b/config/urlConf.py @@ -587,6 +587,16 @@ urls = { "is_json": True, }, - - + "autoVerifyImage": { # 云打码接口 + "req_url": "/verify/base64/", + "req_type": "post", + "Referer": "", + "Host": "111.230.237.182:8000", + "re_try": 2, + "re_time": 2, + "s_time": 2, + "is_logger": True, + "is_json": True, + "httpType": "http" + }, } \ No newline at end of file diff --git a/init/select_ticket_info.py b/init/select_ticket_info.py index 45fb432..d436b58 100755 --- a/init/select_ticket_info.py +++ b/init/select_ticket_info.py @@ -36,7 +36,7 @@ class select: def __init__(self): self.get_ticket_info() self._station_seat = [seat_conf[x] for x in TickerConfig.SET_TYPE] - self.auto_code_type = 2 + self.auto_code_type = TickerConfig.AUTO_CODE_TYPE self.httpClint = HTTPClient(TickerConfig.IS_PROXY) self.urls = urlConf.urls self.login = GoLogin(self, TickerConfig.IS_AUTO_CODE, self.auto_code_type) @@ -55,10 +55,14 @@ class select: 获取配置信息 :return: """ + print(u"*" * 50) print(f"检查当前版本为: {TickerConfig.RE_VERSION}") - print(u"检查当前python版本为:{},目前版本只支持3.6以上".format(sys.version.split(" ")[0])) - print(u"12306刷票小助手,最后更新于2019.09.15,请勿作为商业用途,交流群号:" + version = sys.version.split(" ")[0] + print(u"检查当前python版本为:{},目前版本只支持3.6以上".format(version)) + if version < "3.6.0": + raise Exception + print(u"12306刷票小助手,最后更新于2019.09.18,请勿作为商业用途,交流群号:" u" 1群:286271084(已满)\n" u" 2群:649992274(已满)\n" u" 3群:632501142(已满)\n" @@ -69,7 +73,7 @@ class select: u" 8群: 620629239(未满)\n" ) print( - f"当前配置:\n出发站:{TickerConfig.FROM_STATION}\n到达站:{TickerConfig.TO_STATION}\n乘车日期:{','.join(TickerConfig.STATION_DATES)}\n坐席:{','.join(TickerConfig.SET_TYPE)}\n是否有票优先提交:{TickerConfig.IS_MORE_TICKET}\n乘车人:{TickerConfig.TICKET_PEOPLES}\n" \ + f"当前配置:\n出发站:{TickerConfig.FROM_STATION}\n到达站:{TickerConfig.TO_STATION}\n车次: {','.join(TickerConfig.STATION_TRAINS) or '所有车次'}\n乘车日期:{','.join(TickerConfig.STATION_DATES)}\n坐席:{','.join(TickerConfig.SET_TYPE)}\n是否有票优先提交:{TickerConfig.IS_MORE_TICKET}\n乘车人:{TickerConfig.TICKET_PEOPLES}\n" \ f"刷新间隔: 随机(1-3S)\n僵尸票关小黑屋时长: {TickerConfig.TICKET_BLACK_LIST_TIME}\n下单接口: {TickerConfig.ORDER_TYPE}\n下单模式: {TickerConfig.ORDER_MODEL}\n预售踩点时间:{TickerConfig.OPEN_TIME}") print(u"*" * 50) @@ -244,7 +248,7 @@ class select: else: random_time = round(random.uniform(sleep_time_s, sleep_time_t), 2) nateMsg = ' 无候补机会' if TickerConfig.ORDER_TYPE == 2 else "" - print(f"正在第{num}次查询 随机停留时长:{random_time} 乘车日期: {','.join(TickerConfig.STATION_DATES)} 车次:{'.'.join(TickerConfig.STATION_TRAINS)} 下单无票{nateMsg} 耗时:{(datetime.datetime.now() - now).microseconds / 1000}ms") + print(f"正在第{num}次查询 随机停留时长:{random_time} 乘车日期: {','.join(TickerConfig.STATION_DATES)} 车次:{','.join(TickerConfig.STATION_TRAINS) or '所有车次'} 下单无票{nateMsg} 耗时:{(datetime.datetime.now() - now).microseconds / 1000}ms") time.sleep(random_time) except PassengerUserException as e: print(e) diff --git a/inter/GetRandCode.py b/inter/GetRandCode.py index b953d55..4529671 100644 --- a/inter/GetRandCode.py +++ b/inter/GetRandCode.py @@ -1,6 +1,8 @@ # coding=utf-8 from PIL import Image +from config.urlConf import urls +from myUrllib.httpUtils import HTTPClient from verify.localVerifyCode import verify @@ -14,9 +16,15 @@ def getRandCode(is_auto_code, auto_code_type, result): if auto_code_type == 1: print(u"打码兔已关闭, 如需使用自动识别,请使用如果平台 auto_code_type == 2") return - if auto_code_type == 2: + elif auto_code_type == 2: Result = verify(result) return codexy(Ofset=Result, is_raw_input=False) + elif auto_code_type == 3: + print("您已设置使用云打码,但是服务器资源有限,请尽快改为本地打码") + http = HTTPClient(0) + Result = http.send(urls.get("autoVerifyImage"), {"imageFile": result}) + if Result and Result.get("code") is 0: + return codexy(Ofset=Result.get("data"), is_raw_input=False) else: img = Image.open('./tkcode.png') img.show() diff --git a/inter/Query.py b/inter/Query.py index 6c86645..194d412 100644 --- a/inter/Query.py +++ b/inter/Query.py @@ -53,7 +53,7 @@ class query: :param ticket_info: :return: """ - if self.station_dates: + if self.station_dates and self.station_trains: return ticket_info[3] in self.station_trains else: return True @@ -119,7 +119,7 @@ class query: self.to_station_h, seat_conf_2[j], ticket_num)) - if seat_conf_2[j] == "无座" and ticket_info[3][0] in ["G", "D"]: + if seat_conf_2[j] == "无座" and ticket_info[3][0] in ["G", "D", "C"]: seat = 30 # GD开头的无座直接强制改为二等座车次 if wrapcache.get(train_no): print(ticket.QUERY_IN_BLACK_LIST.format(train_no)) diff --git a/myUrllib/httpUtils.py b/myUrllib/httpUtils.py index aacecc3..4e5cf66 100755 --- a/myUrllib/httpUtils.py +++ b/myUrllib/httpUtils.py @@ -135,7 +135,7 @@ class HTTPClient(object): self.setHeadersReferer(urls["Referer"]) if is_logger: logger.log( - u"url: {0}\n入参: {1}\n请求方式: {2}\n".format(req_url, data, method, )) + u"url: {0}\n入参: {1}\n请求方式: {2}\n".format(req_url, data, method)) self.setHeadersHost(urls["Host"]) if is_test_cdn: url_host = self._cdn @@ -157,7 +157,7 @@ class HTTPClient(object): except: pass response = self._s.request(method=method, - timeout=2, + timeout=5, proxies=self._proxies, url=http + "://" + url_host + req_url, data=data, diff --git a/verify/localVerifyCode.py b/verify/localVerifyCode.py index eadb6b8..9df7c18 100644 --- a/verify/localVerifyCode.py +++ b/verify/localVerifyCode.py @@ -1,14 +1,14 @@ # coding: utf-8 -import base64 -import os +import TickerConfig +if TickerConfig.AUTO_CODE_TYPE == 2: + import base64 + import os + import cv2 + import numpy as np + from keras import models, backend + from verify import pretreatment + from verify.mlearn_for_image import preprocess_input -import cv2 -import numpy as np -from keras import models, backend - - -from verify import pretreatment -from verify.mlearn_for_image import preprocess_input PATH = lambda p: os.path.abspath( os.path.join(os.path.dirname(__file__), p) ) diff --git a/verify/mlearn_for_image.py b/verify/mlearn_for_image.py index 2199f67..bfe4e33 100644 --- a/verify/mlearn_for_image.py +++ b/verify/mlearn_for_image.py @@ -1,14 +1,16 @@ # coding: utf-8 -import sys +import TickerConfig +if TickerConfig.AUTO_CODE_TYPE == 2: + import sys -import cv2 -import numpy as np -from keras import models -from keras import layers -from keras import optimizers -from keras.applications import VGG16 -from keras.callbacks import ReduceLROnPlateau -from keras.preprocessing.image import ImageDataGenerator + import cv2 + import numpy as np + from keras import models + from keras import layers + from keras import optimizers + from keras.applications import VGG16 + from keras.callbacks import ReduceLROnPlateau + from keras.preprocessing.image import ImageDataGenerator def preprocess_input(x): diff --git a/verify/pretreatment.py b/verify/pretreatment.py index 39dcae5..9171434 100644 --- a/verify/pretreatment.py +++ b/verify/pretreatment.py @@ -3,14 +3,16 @@ # 功能:对图像进行预处理,将文字部分单独提取出来 # 并存放到ocr目录下 # 文件名为原验证码文件的文件名 -import hashlib -import os -import pathlib - -import cv2 -import numpy as np -import requests -import scipy.fftpack +import TickerConfig +if TickerConfig.AUTO_CODE_TYPE == 2: + import hashlib + import os + import pathlib + + import cv2 + import numpy as np + import requests + import scipy.fftpack PATH = 'imgs'