Exemple #1
0
def sendPushBear(msg):
    """
    pushBear微信通知
    :param str: 通知内容 content
    :return:
    """
    conf = _get_yaml()
    if conf["pushbear_conf"][
            "is_pushbear"] and conf["pushbear_conf"]["send_key"].strip() != "":
        try:
            sendPushBearUrls = urls.get("Pushbear")
            data = {
                "sendkey": conf["pushbear_conf"]["send_key"].strip(),
                "text":
                "易行购票成功通知,{}".format(time.strftime("%Y-%m-%d %H:%M:%S")),
                "desp": msg
            }
            httpClint = HTTPClient(0)
            sendPushBeaRsp = httpClint.send(sendPushBearUrls, data=data)
            if sendPushBeaRsp.get("code") is 0:
                print(u"已下发 pushbear 微信通知, 请查收")
            else:
                print(sendPushBeaRsp)
        except Exception as e:
            print(u"pushbear 配置有误 {}".format(e))
    else:
        pass
Exemple #2
0
def getRandCode(is_auto_code, auto_code_type, result):
    """
    识别验证码
    :return: 坐标
    """
    try:
        if is_auto_code:
            if auto_code_type == 1:
                print(u"打码兔已关闭, 如需使用自动识别,请使用如果平台 auto_code_type == 2")
                return
            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()
            return codexy()
    except Exception as e:
        print(e)
Exemple #3
0
def send_push_bear(msg):
    """
    pushBear微信通知
    :param msg: 通知内容 content
    :return:
    """
    if TickerConfig.PUSHBEAR_CONF[
            "is_pushbear"] and TickerConfig.PUSHBEAR_CONF["send_key"].strip(
            ) != "":
        try:
            send_push_bear_urls = urls.get("Pushbear")
            data = {
                "sendkey": TickerConfig.PUSHBEAR_CONF["send_key"].strip(),
                "text": "购票成功通知",
                "desp": msg
            }
            http_client = HTTPClient(0)
            send_push_bea_rsp = http_client.send(send_push_bear_urls,
                                                 data=data)
            if send_push_bea_rsp.get("code") is 0:
                print(u"已下发 pushbear 微信通知, 请查收")
            else:
                print(send_push_bea_rsp)
        except Exception as e:
            print(u"pushbear 配置有误 {}".format(e))
    else:
        pass
Exemple #4
0
 def __init__(
     self,
     session,
     from_station,
     to_station,
     from_station_h,
     to_station_h,
     _station_seat,
     station_trains,
     ticke_peoples_num,
     station_dates=None,
 ):
     self.session = session
     self.httpClint = HTTPClient()
     self.urls = urlConf.urls
     self.from_station = from_station
     self.to_station = to_station
     self.from_station_h = from_station_h
     self.to_station_h = to_station_h
     self.station_trains = station_trains
     self._station_seat = _station_seat if isinstance(
         _station_seat, list) else list(_station_seat)
     self.station_dates = station_dates if isinstance(
         station_dates, list) else list(station_dates)
     self.ticket_black_list = dict()
     self.ticke_peoples_num = ticke_peoples_num
     # by time
     self.is_by_time = session.is_by_time
     self.train_types = session.train_types
     self.departure_time = session.departure_time
     self.arrival_time = session.arrival_time
     self.take_time = session.take_time
Exemple #5
0
def sendPushBear(msg):
    """
    pushBear微信通知
    :param str: 通知内容 content
    :return:
    """
    conf = _get_yaml()
    user = _get_yaml()["set"]["12306account"][0]["user"]
    if conf["pushbear_conf"][
            "is_pushbear"] and conf["pushbear_conf"]["send_key"].strip() != "":
        try:
            sendPushBearUrls = urls.get("Pushbear")
            data = {
                "sendkey": conf["pushbear_conf"]["send_key"].strip(),
                "text": user + "购票成功通知",
                "desp": msg
            }
            httpClint = HTTPClient(0)
            sendPushBeaRsp = httpClint.send(sendPushBearUrls, data=data)
            if sendPushBeaRsp.get("code") is 0:
                print(u"已下发 pushbear 微信通知, 请查收")
            else:
                print(sendPushBeaRsp)
        except Exception as e:
            print(u"pushbear 配置有误 {}".format(e))
    else:
        pass
def sendPushBear(msg):
    """
	pushBear微信通知
	:param str:通知内容 content
	:return:
	"""
    # print()
    if configMap["pushbear_conf"]["is_pushbear"] and configMap[
            "pushbear_conf"]["send_key"].strip() != "":
        # if 1!=2:
        try:
            sendPushBearUrls = urlConf.urls["Pushbear"]
            print(sendPushBearUrls)
            data = {
                "send_key": configMap["pushbear_conf"]["send_key"].strip(),
                "text": "列车正晚点信息",
                "desp": msg
            }
            #以下方法测试老是报pushbear配置有误
            HTTPClient1 = HTTPClient(0)
            sendPushBearRSP = HTTPClient1.send(sendPushBearUrls, data=data)
            # print(sendPushBearRSP)
            # if sendPushBearRSP["errno"] is 0:
            if sendPushBearRSP.get("errno") is 0:
                print(u"已下发 pushbear 微信通知,请查收")
            else:
                print(sendPushBearRSP)
        except Exception as e:
            print(u"pushbear配置有误{}".format(e))
        else:
            pass
        finally:
            pass
    else:
        pass
Exemple #7
0
 def __init__(
     self,
     select_obj,
     from_station,
     to_station,
     from_station_h,
     to_station_h,
     _station_seat,
     station_trains,
     ticke_peoples_num,
     station_dates=None,
 ):
     self.session = select_obj
     self.httpClient = HTTPClient(TickerConfig.IS_PROXY)
     self.httpClient.set_cookies(self.session.cookies)
     self.urls = urlConf.urls
     self.from_station = from_station
     self.to_station = to_station
     self.from_station_h = from_station_h
     self.to_station_h = to_station_h
     self.station_trains = station_trains
     self._station_seat = _station_seat if isinstance(
         _station_seat, list) else list(_station_seat)
     self.station_dates = station_dates if isinstance(
         station_dates, list) else list(station_dates)
     self.ticket_black_list = dict()
     self.ticke_peoples_num = ticke_peoples_num
Exemple #8
0
 def cdn_req(self, cdn):
     for i in range(len(cdn)-1):
         http = HTTPClient()
         urls = self.confUrl["loginInit"]
         start_time = datetime.datetime.now()
         http.cdn = cdn[i].replace("\n", "")
         rep = http.send(urls)
         if rep and "message" not in rep and (datetime.datetime.now() - start_time).microseconds / 1000 < 300:
             self.cdn_list.append(cdn[i].replace("\n", ""))
     print(u"所有cdn解析完成...")
Exemple #9
0
 def __init__(self, session=None, is_auto_code=False, auto_code_type=1):
     if session is None:
         self.session = self
     else:
         self.session = session
     self.randCode = ""
     self.is_auto_code = is_auto_code
     self.auto_code_type = auto_code_type
     self.urls = urls
     self.httpClint = HTTPClient()
Exemple #10
0
 def cdn_req(self, cdn):
     for i in range(len(cdn) - 1):
         http = HTTPClient(0)
         urls = self.urls["loginInitCdn"]
         http._cdn = cdn[i].replace("\n", "")
         start_time = datetime.datetime.now()
         rep = http.send(urls)
         if rep and "message" not in rep and (datetime.datetime.now() - start_time).microseconds / 1000 < 500:
             if cdn[i].replace("\n", "") not in self.cdn_list:  # 如果有重复的cdn,则放弃加入
                 # print(u"加入cdn {0}".format(cdn[i].replace("\n", "")))
                 self.cdn_list.append(cdn[i].replace("\n", ""))
     print(u"所有cdn解析完成...")
Exemple #11
0
 def run(self):
     for cdn in self.cdns:
         http = HTTPClient(0)
         url = urls["loginInitCdn"]
         http._cdn = cdn.replace("\n", "")
         start_time = datetime.datetime.now()
         rep = http.send(url)
         if rep and "message" not in rep and (datetime.datetime.now(
         ) - start_time).microseconds / 1000 < 1000:
             if cdn.replace("\n", "") not in cdn_list:  # 如果有重复的cdn,则放弃加入
                 print(f"加入cdn: {cdn}")
                 cdn_list.append(cdn.replace("\n", ""))
Exemple #12
0
 def __init__(self):
     self.from_station, self.to_station, self.station_dates, self._station_seat, self.is_more_ticket, \
     self.ticke_peoples, self.station_trains, self.ticket_black_list_time, \
     self.order_type = self.get_ticket_info()
     self.is_auto_code = _get_yaml()["is_auto_code"]
     self.auto_code_type = _get_yaml()["auto_code_type"]
     self.is_cdn = _get_yaml()["is_cdn"]
     self.httpClint = HTTPClient()
     self.urls = urlConf.urls
     self.login = GoLogin(self, self.is_auto_code, self.auto_code_type)
     self.cdn_list = []
     self.passengerTicketStrList = ""
     self.oldPassengerStr = ""
 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.httpClint = HTTPClient(TickerConfig.IS_PROXY)
     self.urls = urlConf.urls
     self.login = GoLogin(self, TickerConfig.IS_AUTO_CODE, self.auto_code_type)
     self.cdn_list = []
     self.queryUrl = "leftTicket/queryT"
     self.passengerTicketStrList = ""
     self.passengerTicketStrByAfterLate = ""
     self.oldPassengerStr = ""
     self.set_type = ""
Exemple #14
0
def sendServerChan(msg):

    try:
        sendPushBearUrls = urls.get("ServerChan")
        data = {"text": "自定义购票成功通知测试版本", "desp": msg}
        httpClint = HTTPClient(0)
        sendPushBeaRsp = httpClint.send(sendPushBearUrls, data=data)
        if sendPushBeaRsp.get("code") is 0:
            print(u"已下发 serverChan 微信通知, 请查收")
        else:
            print(sendPushBeaRsp)
    except Exception as e:
        print(u"serverChan 配置有误 {}".format(e))
    pass
 def __init__(self):
     self.from_station, self.to_station, self.station_dates, self._station_seat, self.is_more_ticket, self.ticke_peoples, self.select_refresh_interval, self.station_trains, self.expect_refresh_interval, self.ticket_black_list_time = self.get_ticket_info(
     )
     self.order_request_params = {}  # 订单提交时的参数
     self.ticketInfoForPassengerForm = {}  # 初始化当前页面参数
     self.current_seats = {}  # 席别信息
     self.token = ""
     self.set_type = ""
     self.user_info = ""
     self.secretStr = ""
     self.ticket_black_list = dict()
     self.is_check_user = dict()
     self.httpClint = HTTPClient()
     self.confUrl = urlConf.urls
 def __init__(self):
     self.cdn_list = open_cdn_file("filter_cdn_list")
     self.get_ticket_info()
     self._station_seat = [seat_conf[x] for x in TickerConfig.SET_TYPE]
     self.auto_code_type = TickerConfig.AUTO_CODE_TYPE
     self.httpClint = HTTPClient(TickerConfig.IS_PROXY, self.cdn_list)
     self.httpClint.cdn = self.cdn_list[random.randint(0, 4)]
     self.urls = urlConf.urls
     self.login = GoLogin(self, TickerConfig.IS_AUTO_CODE, self.auto_code_type)
     self.cookies = ""
     self.queryUrl = "leftTicket/queryO"
     self.passengerTicketStrList = ""
     self.passengerTicketStrByAfterLate = ""
     self.oldPassengerStr = ""
     self.set_type = ""
     self.flag = True
Exemple #17
0
 def __init__(self):
     self.from_station, self.to_station, self.station_dates, self._station_seat, self.is_more_ticket, \
     self.ticke_peoples, self.station_trains, self.ticket_black_list_time, \
     self.order_type, self.is_by_time, self.train_types, self.departure_time, \
     self.arrival_time, self.take_time, self.order_model, self.open_time, self.is_proxy = self.get_ticket_info()
     self.is_auto_code = _get_yaml()["is_auto_code"]
     self.auto_code_type = _get_yaml()["auto_code_type"]
     self.is_cdn = _get_yaml()["is_cdn"]
     self.httpClint = HTTPClient(self.is_proxy)
     self.urls = urlConf.urls
     self.login = GoLogin(self, self.is_auto_code, self.auto_code_type)
     self.cdn_list = []
     self.queryUrl = "leftTicket/queryZ"
     self.passengerTicketStrList = ""
     self.oldPassengerStr = ""
     self.set_type = ""
Exemple #18
0
 def __init__(self, qiangpiao_info=None):
     if qiangpiao_info is None:
         self.from_station, self.to_station, self.station_dates, self._station_seat, self.is_more_ticket, \
         self.ticke_peoples, self.station_trains, self.ticket_black_list_time, \
         self.order_type = self.get_ticket_info()
     else:
         pass
     self.is_auto_code = _get_yaml()["is_auto_code"]
     self.auto_code_type = _get_yaml()["auto_code_type"]
     self.is_cdn = _get_yaml()["is_cdn"]
     self.httpClint = HTTPClient()
     self.urls = urlConf.urls
     self.login = GoLogin(self, self.is_auto_code, self.auto_code_type)
     self.cdn_list = []
     self.passengerTicketStrList = ""
     self.oldPassengerStr = ""
     self.station_name_map = self.station_table(
         '../config/station_name.format')
Exemple #19
0
 def __init__(self, session, station_dates=None):
     self.httpClint = HTTPClient()
     self.urls = urlConf.urls
     self.qiangpiao = True
     self.session = session
     if station_dates is None:
         station_dates = (datetime.date.today() +
                          datetime.timedelta(2)).strftime('%Y-%m-%d')
     # print station_dates
     self.station_dates = station_dates if isinstance(
         station_dates, list) else [station_dates]
     self.ticket_black_list = dict()
     self.train_info_dict = self.get_train_info(train_info_path)
     self.station_info_dict, self.re_station_info_dict = self.get_station_info(
         station_info_path)
     self.start_station, self.end_station = self.get_station2station_file(
         '../data/station2station.info')
     self.station_time = self.get_station2station_spendtime_duration(
         '../data/station2station.spendtime.duration')
Exemple #20
0
 def __init__(self):
     self.from_station, self.to_station, self.station_dates, self._station_seat, self.is_more_ticket, self.ticke_peoples, self.select_refresh_interval, self.station_trains, self.ticket_black_list_time = self.get_ticket_info()
     self.is_aotu_code = _get_yaml()["is_aotu_code"]
     self.aotu_code_type = _get_yaml()["aotu_code_type"]
     self.is_cdn = _get_yaml()["is_cdn"]
     self.order_request_params = {}  # 订单提交时的参数
     self.ticketInfoForPassengerForm = {}  # 初始化当前页面参数
     self.current_seats = {}  # 席别信息
     self.token = ""
     self.set_type = ""
     self.user_info = ""
     self.secretStr = ""
     self.ticket_black_list = dict()
     self.is_check_user = dict()
     self.httpClint = HTTPClient()
     self.confUrl = urlConf.urls
     self.login = GoLogin(self.httpClint, self.confUrl, self.is_aotu_code, self.aotu_code_type)
     self.is_download_img = False
     self.randCode = ""
     self.cdn_list = []
def send_server_chan(msg):
    """
    pushBear微信通知
    :param msg: 通知内容 content
    :return:
    """
    if (TickerConfig.SERVER_CHAN_CONF["is_server_chan"]
            and TickerConfig.SERVER_CHAN_CONF["secret"].strip() != ""):
        try:
            secret = TickerConfig.SERVER_CHAN_CONF["secret"].strip()
            send_server_chan_urls = urls.get("ServerChan")
            send_server_chan_urls["req_url"] += f'{secret}.send'

            params = {"text": "购票成功通知", "desp": msg}
            http_client = HTTPClient(0)
            send_server_chan_rsp = http_client.send(send_server_chan_urls,
                                                    params=params)
            if send_server_chan_rsp.get("errno") == 0:
                print(u"已下发 Server酱 微信通知, 请查收")
            else:
                print(send_server_chan_rsp)
        except Exception as e:
            print(u"Server酱 配置有误 {}".format(e))
# coding=utf-8
from config.urlConf import urls
from myUrllib.httpUtils import HTTPClient

httpClint = HTTPClient()


def getPassCodeNewOrderAndLogin(session, imgType):
    """
    下载验证码
    :param session:
    :param imgType: 下载验证码类型,login=登录验证码,其余为订单验证码
    :return:
    """
    if imgType == "login":
        codeImgUrl = urls["getCodeImg"]
        print codeImgUrl
        # codeImgUrl = session.urls["getCodeImg"]
    else:
        # codeImgUrl = session.urls["codeImgByOrder"]
        codeImgUrl = urls["codeImgByOrder"]
    print(u"下载验证码...")
    img_path = '../flask_app/static/images/login/tkcode.png'
    # result = session.httpClint.send(codeImgUrl)
    print codeImgUrl
    result = session.httpClint.send(codeImgUrl)
    try:
        print(u"下载验证码成功")
        open(img_path, 'wb').write(result)
    except OSError:
        print(u"验证码下载失败,可能ip被封,确认请手动请求: {0}".format(codeImgUrl))