import re as m_re import os as m_os import time as m_time import random as m_random import easygui as m_easygui import requests as m_requests class HtmlInfo(): def __init__(self): self.browser_header = { "User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36" "(KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"} self.ddd_nums = {} self.ssq_nums = {} self.qlc_nums = {} self.urls = [ r'http://kaijiang.500.com/sd.shtml', r'http://kaijiang.500.com/ssq.shtml', r'http://kaijiang.500.com/qlc.shtml' ] self.html_lable = [ r'<span class="span_right">(.*?)</span>', r'<strong>(.*?)</strong>', r'<li class="ball_orange">(.*?)</li>', r'<li class="ball_red">(.*?)</li>', r'<li class="ball_blue">(.*?)</li>', r'<li class="ball_red">(.*?)</li>', r'<li class="ball_blue">(.*?)</li>' ] def get_HtmlInfo(self, url): try: html = m_requests.get(url, headers=self.browser_header) html.encoding = 'gbk' except TypeError: print('网络中断或其他原因!') return if self.urls[0] == url: self.lottery_date = m_re.findall(self.html_lable[0], html.text, m_re.S)[0] lottery_date_nums = m_re.findall(self.html_lable[1], html.text, m_re.S)[1] lottery_nums = m_re.findall(self.html_lable[2], html.text, m_re.S) self.ddd_nums[lottery_date_nums] = lottery_nums if self.urls[1] == url: lottery_nums = [] lottery_date = m_re.findall(self.html_lable[0], html.text, m_re.S)[0] lottery_date_nums = m_re.findall(self.html_lable[1], html.text, m_re.S)[1] lottery_nums_red = m_re.findall(self.html_lable[3], html.text, m_re.S)[:6] lottery_nums_blue = m_re.findall(self.html_lable[4], html.text, m_re.S)[:1] lottery_nums.extend(lottery_nums_red) lottery_nums.extend(lottery_nums_blue) self.ssq_nums[lottery_date_nums] = lottery_nums if self.urls[2] == url: lottery_nums = [] lottery_date = m_re.findall(self.html_lable[0], html.text, m_re.S)[0] lottery_date_nums = m_re.findall(self.html_lable[1], html.text, m_re.S)[1] lottery_nums_red = m_re.findall(self.html_lable[5], html.text, m_re.S)[:7] lottery_nums_blue = m_re.findall(self.html_lable[6], html.text, m_re.S)[:1] lottery_nums.extend(lottery_nums_red) lottery_nums.extend(lottery_nums_blue) self.qlc_nums[lottery_date_nums] = lottery_nums class AppCryptos(): def __init__(self): self.token_list = [ '0000000000_' 'bC0>aB3?aA0!aG1%hI1$' 'eK6)dA8&qB4@lC0$bA0&aI0eP1#cC0$' '!@#$%^&*()_+aF0!bG2!cE4_eC1^bE0^aE4@bC0{nB' ] self.enctry_str = '' self.dectry_str = '' def enctry_AppCryptos(self, key): for i,j in zip(key, str(self.token_list)): temp_ij = str(ord(i) + ord(j)) + str(self.token_list[0][:15]) self.enctry_str += temp_ij return self.enctry_str def dectry_AppCryptos(self, key): for i,j in zip(key.split(str(self.token_list[0][:15]))[:-1], str(self.token_list)): temp_ij = chr(int(i) - ord(j)) self.dectry_str += temp_ij return self.dectry_str class EasyGuiUI(): def __init__(self): self.app_config = [ r'AppConfig.ini', r'MainConfig.ini', r'config_path=', r'configfile_path=', r'username=', r'userkey=' ] self.loop_ddd = (0, 9) self.loop_ssq_red = (1, 33) self.loop_ssq_blue = (1, 16) self.loop_qlc = (1, 30) self.box_msg = [ '欢迎进入彩票号码生成器!\n是否进行程序初始化?\n自定义配置文件目录或程序默认目录', '选择一个文件夹!', '欢迎使用机选彩票号码程序, 祝您早日中大奖!', '请输入程序密码', '注册成功!', '\n\n\n点击下方[查看最新开奖号码]按钮以获取开奖号码' ] self.box_title = [ '程序初始化', '激活程序', '登录验证', '机选号码' ] self.indexbox_choices = [ ['0', '确定'], ['1', '默认'], ['2', '机选号码'], ['3', '查看最新开奖号码'], ['4', '退出程序'] ] self.indexbox_errmsg = [ '未知错误!', '文件不存在', '', '', '主程序文件失效,请重新运行程序!' ] self.multpasswordbox_fields = [ '*昵称', '*程序密码' ] self.temp_enctry_str = '' self.temp_ext_userkey = [] self.temp_ext_username = [] def init_EasyGuiUI(self): try: with open(self.app_config[1], encoding='utf-8') as init_f1: init_f1.close() EasyGuiUI().reg_EasyGuiUI() except OSError: choices_msg = m_easygui.indexbox( self.box_msg[0], self.box_title[0], choices=(self.indexbox_choices[0][1],self.indexbox_choices[1][1]) ) if choices_msg == int(self.indexbox_choices[0][0]): choices_path = m_easygui.diropenbox(self.box_msg[1]) with open(self.app_config[1], 'w', encoding='utf-8') as user_f1: user_f1.write( self.app_config[2] + m_os.getcwd() + ';' + '\n' + self.app_config[3] + m_os.getcwd() + '\\' + self.app_config[1] + ';' ) try: m_os.chdir(choices_path) except TypeError: return merge_path = m_os.path.join(m_os.getcwd(), self.app_config[0]) with open(merge_path, 'w', encoding='utf-8') as user_f2: user_f2.write( self.app_config[2] + choices_path + ';' + '\n' + self.app_config[3] + merge_path + ';' ) EasyGuiUI().reg_EasyGuiUI() elif choices_msg == int(self.indexbox_choices[1][0]): with open(self.app_config[0], 'w', encoding='utf-8') as app_f1,\ open(self.app_config[1], 'w', encoding='utf-8') as app_f2: app_f1.write( self.app_config[2] + m_os.getcwd() + ';' + '\n' + self.app_config[3] + m_os.getcwd() + '\\' + self.app_config[0] + ';' ) app_f2.write( self.app_config[2] + m_os.getcwd() + ';' + '\n' + self.app_config[3] + m_os.getcwd() + '\\' + self.app_config[1] + ';' ) EasyGuiUI().reg_EasyGuiUI() def reg_EasyGuiUI(self): with open(self.app_config[1], 'r', encoding='utf-8') as read_f1: read_f1_temp = read_f1.read() if self.app_config[4] in read_f1_temp and self.app_config[5] in read_f1_temp: return EasyGuiUI().login_EasyGuiUI() reg_values = [] reg_values = m_easygui.multpasswordbox( self.box_msg[2], self.box_title[1], fields=(self.multpasswordbox_fields[0],self.multpasswordbox_fields[1]) ) while True: self.indexbox_errmsg[2] = self.indexbox_errmsg[3] if reg_values == None: return for i in range(len(self.multpasswordbox_fields)): if reg_values[i] == '' and self.multpasswordbox_fields[i][0] == '*' and self.multpasswordbox_fields[i][0] == '*': self.indexbox_errmsg[2] += ('【%s】为必填项,请重新填写!\n' % self.multpasswordbox_fields[i]) if self.indexbox_errmsg[2] == '': break reg_values = m_easygui.multpasswordbox( self.indexbox_errmsg[2], self.box_title[1], fields=(self.multpasswordbox_fields[0],self.multpasswordbox_fields[1]), values=reg_values ) link_AppCryptos = AppCryptos() link_AppCryptos.enctry_AppCryptos(reg_values[1]) self.temp_enctry_str = link_AppCryptos.enctry_str try: with open(self.app_config[1], 'a', encoding='utf-8') as enctry_f1: enctry_f1.write( '\n' + self.app_config[4] + reg_values[0] + ';' + '\n' + self.app_config[5] + self.temp_enctry_str + ';' ) m_easygui.msgbox(self.box_msg[4]) EasyGuiUI().login_EasyGuiUI() except OSError: m_easygui.msgbox(self.indexbox_errmsg[4]) def login_EasyGuiUI(self): login_return_cont = m_easygui.passwordbox(self.box_msg[3], self.box_title[2]) with open(self.app_config[1], encoding='utf-8') as dectry_f1: ext_userkey = m_re.findall(r'userkey=(.*?);', dectry_f1.read(), m_re.S) link_AppCryptos = AppCryptos() link_AppCryptos.dectry_AppCryptos(ext_userkey[0]) if login_return_cont == link_AppCryptos.dectry_str: EasyGuiUI().panel_EasyGuiUI() elif login_return_cont == None: return else: return EasyGuiUI().login_EasyGuiUI() def get_nums_ForPanel(self): link_HtmlInfo = HtmlInfo() for loop_urls in range(len(link_HtmlInfo.urls)): link_HtmlInfo.get_HtmlInfo(link_HtmlInfo.urls[loop_urls]) dict_ddd = link_HtmlInfo.ddd_nums dict_ssq = link_HtmlInfo.ssq_nums dict_qlc = link_HtmlInfo.qlc_nums dict_ddd_value = ','.join(list(dict_ddd.values())[0]) dict_ssq_value = ','.join(list(dict_ssq.values())[0]) dict_qlc_value = ','.join(list(dict_qlc.values())[0]) self.marge_msgs_get_nums_ForPanel = ( '第[' + list(dict_ddd)[0] + ']期福彩3D开奖号码: ' + dict_ddd_value + '\n' + '第[ ' + list(dict_ssq)[0] + ' ]期双色球开奖号码: ' + dict_ssq_value + '\n' + '第[ ' + list(dict_qlc)[0] + ' ]期七乐彩开奖号码: ' + dict_qlc_value ) def get_loopnums_ForPanel(self, keyloopnums): if keyloopnums == 'start': loopnums_1_ddd = [str(m_random.randint(self.loop_ddd[0],self.loop_ddd[1])) for loop in range(3)] loopnums_1_ddd = ','.join(loopnums_1_ddd) loopnums_2_red = [str(m_random.randint(self.loop_ssq_red[0],self.loop_ssq_red[1])) for loop in range(6)] loopnums_2_blue = [str(m_random.randint(self.loop_ssq_blue[0],self.loop_ssq_blue[1])) for loop in range(1)] loopnums_2_red.append(loopnums_2_blue[0]) loopnums_2_ssq = ','.join(loopnums_2_red) loopnums_3_red = [str(m_random.randint(self.loop_qlc[0],self.loop_qlc[1])) for loop in range(7)] loopnums_3_blue = [str(m_random.randint(self.loop_qlc[0],self.loop_qlc[1])) for loop in range(1)] loopnums_3_red.append(loopnums_3_blue[0]) loopnums_3_qlc = ','.join(loopnums_3_red) self.marge_msgs_get_loopnums_ForPanel = ( '机选的福彩3D号码: ' + loopnums_1_ddd + '\n' + '机选的双色球号码: ' + loopnums_2_ssq + '\n' + '机选的七乐彩号码: ' + loopnums_3_qlc + '\n' + '截屏或拍照后去彩票站购买, 祝你鸿运当头!' ) else: pass def panel_EasyGuiUI(self): self.get_nums_ForPanel() with open(self.app_config[1], encoding='utf-8') as read_f1: ext_username = m_re.findall(r'username=(.*?);', read_f1.read(), m_re.S) get_time = m_time.localtime() if 0 <= get_time.tm_hour <= 4: indexbox_msg_time = '凌晨时段,注意休息: ' elif 5 <= get_time.tm_hour <= 10: indexbox_msg_time = '早上好: ' elif 11 <= get_time.tm_hour <= 12: indexbox_msg_time = '中午好: ' elif 13 <= get_time.tm_hour <= 18: indexbox_msg_time = '下午好: ' elif 19 <= get_time.tm_hour <= 23: indexbox_msg_time = '晚上好: ' else: indexbox_msg_time = '奈何桥见: ' choices_msg = m_easygui.indexbox( msg=(indexbox_msg_time + ext_username[0] + self.box_msg[5]), title=self.box_title[3], choices=(self.indexbox_choices[2][1],self.indexbox_choices[3][1],self.indexbox_choices[4][1]) ) while True: if choices_msg == 0: self.get_loopnums_ForPanel('start') choices_msg = m_easygui.indexbox( msg=self.marge_msgs_get_loopnums_ForPanel, title=self.box_title[3], choices=(self.indexbox_choices[2][1],self.indexbox_choices[3][1],self.indexbox_choices[4][1]) ) elif choices_msg == 1: choices_msg = m_easygui.indexbox( msg=self.marge_msgs_get_nums_ForPanel, title=self.box_title[3], choices=(self.indexbox_choices[2][1],self.indexbox_choices[3][1],self.indexbox_choices[4][1]) ) elif choices_msg == 2: break else: break app_run = EasyGuiUI() app_run.init_EasyGuiUI()