import concurrent.futures import requests from concurrent.futures import ThreadPoolExecutor, as_completed from sqlalchemy import Column,String,create_engine #,event from sqlalchemy.orm import sessionmaker from sqlalchemy.ext.declarative import declarative_base import pyodbc import copy import pandas as pd import csv import requests import json import rsa import binascii import json import csv import pandas as pd import datetime import random import sys import time from bs4 import BeautifulSoup import re from PyQt5.QtCore import QThread, pyqtSignal from PyQt5.QtWidgets import (QApplication, QDialog, QProgressBar, QPushButton,QLabel) from PyQt5 import QtWidgets from PyQt5.QtCore import * from sqlalchemy import Column,String,create_engine from sqlalchemy.orm import sessionmaker from sqlalchemy.ext.declarative import declarative_base import pyodbc import os import logging import traceback import atexit FORMAT = '%(asctime)s %(levelname)s: %(message)s' logging.basicConfig(level=logging.INFO, filename='myLog.log', filemode='w', format=FORMAT) Base = declarative_base() class Logdata(Base): __tablename__ = 'LOGDB' 資料庫 = Column(String(20), primary_key=True) IP位置 = Column(String(20)) 帳號 = Column(String(20)) 密碼 = Column(String(20)) class User(Base): __tablename__ = '客戶資料表' 客戶 = Column(String(20), primary_key=True) 資料庫 = Column(String(20)) IP位置 = Column(String(20)) 帳號 = Column(String(20)) 密碼 = Column(String(20)) class DateF(Base): __tablename__ = '查詢時間' 開始=Column(String(20), primary_key=True) 結束=Column(String(20)) 是否全導=Column(String(20)) class Someoneupdate(Base): __tablename__ = '自動導入判斷' 正在自動導入中= Column(String(20), primary_key=True) def loadCSV(): try: with open('000.csv', newline='') as csvfile: rows = csv.reader(csvfile) csvvrow=[] for row in rows: csvvrow.append(row) coustomtxt=(csvvrow[1][0]) bdtxtcrypto=(csvvrow[2][0]) #====================================解密========================== PRIVATTTTT=693199020841184529005187339596013597950466957598599888793608033530271219415853952414609432155441426597962873618644988823224505129033188472492232565627111731743840442387622658441932249274048207290194890312931801018119336565101207159089093817844379836520246765598761731093447853178093855957965143730121353938159096214435813116478583463281838568325696377260624492699103838269489173425735163766515881745838239102851526971498900537039965925229366981233886305256752613857576375123305107336285923247046744901857058559811348110224118414002814652550587381981742663420856507553321403129123387307759852585845583253705194423896104474967966535066409675943348475929657759428664521337873475544406762447015072876289975051669953965932555224693025757002523361150649200905802416556626834350633483715061798581642291839762255979334372982156774414505811030453728205541010293992016524698689810201483053731487961892768615175941360043106707261541518852778287823654935902238415934276399863697899069150965902889645358960710613979521286008786269668237598187906056491031301559442316212834296436205439154886053776090316790598915161638161668892006476380622662058436463540372859165165728327478177043147902958378365406901451035507793539047616182219516942468776336379 #PrivateKey A1=435136098972877768874748645248339158125703956065257805897130489515873898645785064137580564100320503666838498219287367368030775233887671705599248600291953393231454780648861079171195672717473628632853618453449217420455794237632155291175461656351373149436294485404694429947256530385791280349340495413483412113186857182441596591220416636342090069157129915377951859333634936029548424638926391232291634636038258059603109206715187896810765799441703590963590776385210580000409455669280693512175818186066741512695081131148497030784289903926969375944559780083722346620544362180693184053719440253987062360057770451705216722616373945761278697477867656454308042535057052004210508850990364826097246310462235289453838547367442863138161099765610183693493835956264409463595891562624222255540841617618186384919177648960630843478742501992844305124096538648231123014949030890404247398161443680124720970242595119682693770042136274011065565273819531541118246115073819134261046370918950429149073365625538812772489582690787721407799409054150416184648077711942774002489730938839028835996373562349388498470086161265863994312489374464512279091382150353090705188164569282723516063722137626802108564462453248942121100848000690940344201632450119420978307322308945 A2=9627714051932950193134188501742994592784042206914443459734438308841410040354738469881718445461422881776007294906803790685427277699734850787185938262102876531473114260174800542552232307443022494368143100728406826855674366796656059054215802558213346170105688323652674928367680251460924362233864869984871966783909100785712414620921144535418728448391075664442600744983428543175164409720230286595771434578391588137898216407341812591598354427012529961000712417819821596260309468611766323842906019082923549785615976305556417630687246871293866806059225782724368215141401076633953519395967986211659258251543120569378038365122086876706827618666557619122782700896147 A3=72000374865933143340744306653169834428832683081115110740204100237805467875781399111076588189449270231784547205065314993551385284482420372845976820023615822918370850049018336485262561074750111640775157594829249815372287322731748252778906894672575675394415480712584447066603079224388770970172603768779881242086210954654794512868330782099170594476257989194451530266257956383540560124814995186866139904562390161487741092810396910518052928540664299189962055810713116703112503213279177866017925218355080344908808970420740591501342146164000394175136511345019472809580649061686926648057 bdtxtcrypto=bdtxtcrypto.encode('utf8') print(bdtxtcrypto) print(type(bdtxtcrypto)) bdtxtcrypto=binascii.a2b_hex(bdtxtcrypto) mmmmm=rsa.decrypt(bdtxtcrypto,rsa.PrivateKey(PRIVATTTTT,65537,A1,A2,A3)) bdtxt=(mmmmm.decode('utf8')) #====================================解密========================== return coustomtxt,bdtxt except: traceback.print_exc() # 捕捉異常,並將異常傳播資訊輸出控制檯 traceback.print_exc(file=open('log.txt', 'a')) logging.debug('debug message',exc_info=True) logging.info('info message',exc_info=True) logging.warning('warning message',exc_info=True) logging.error('error message',exc_info=True) logging.critical('critical message',exc_info=True) app1 = QtWidgets.QApplication([]) error_dialog = QtWidgets.QErrorMessage() error_dialog.setWindowTitle('ERROR') error_dialog.showMessage('無法取得000.csv') app1.exec_() def connectEngine(coustomtxt,engine): try: DB_session = sessionmaker(engine) db_session = DB_session() comDbUserData=db_session.query(User).filter(User.客戶.like(coustomtxt)).all() UserDbName=comDbUserData[0].資料庫 UserIPName=comDbUserData[0].IP位置 UserAdName=comDbUserData[0].帳號 UserPdName=comDbUserData[0].密碼 engine3 = create_engine('mssql+pyodbc://'+UserAdName+':'+UserPdName+'@'+UserIPName+'/'+UserDbName+'?driver=SQL+Server+Native+Client+11.0',fast_executemany=True) # engine3 = create_engine('mssql+pyodbc://'+UserAdName+':'+UserPdName+'@'+UserIPName+'/'+UserDbName+'?driver=SQL+Server+Native+Client+11.0') return engine3 except: traceback.print_exc() # 捕捉異常,並將異常傳播資訊輸出控制檯 traceback.print_exc(file=open('log.txt', 'a')) logging.debug('debug message',exc_info=True) logging.info('info message',exc_info=True) logging.warning('warning message',exc_info=True) logging.error('error message',exc_info=True) logging.critical('critical message',exc_info=True) app1 = QtWidgets.QApplication([]) error_dialog = QtWidgets.QErrorMessage() error_dialog.setWindowTitle('ERROR') error_dialog.showMessage('資料連線失敗') app1.exec_() def DateDataLoad(engine3,db_session2): try: #engine3=connectEngine() Datefind=db_session2.query(DateF).all() startdatekey=Datefind[0].開始 enddatekey=Datefind[0].結束 allpart=Datefind[0].是否全導 return startdatekey,enddatekey,allpart except: traceback.print_exc() # 捕捉異常,並將異常傳播資訊輸出控制檯 traceback.print_exc(file=open('log.txt', 'a')) logging.debug('debug message',exc_info=True) logging.info('info message',exc_info=True) logging.warning('warning message',exc_info=True) logging.error('error message',exc_info=True) logging.critical('critical message',exc_info=True) app1 = QtWidgets.QApplication([]) error_dialog = QtWidgets.QErrorMessage() error_dialog.setWindowTitle('ERROR') error_dialog.showMessage('導入日期資料失敗') app1.exec_() def LoadCustomData(engine3,allpart): try: editim = "CC1,CC2,CC3,CC4,CC5,CC6,CC7,CC8,CC9,CC10,CC11,CC12,CC13,CC14,CC15,CC16,CC17,CC18,CC19,CC20,CC21,CC22,CC23,CC24,CC25,CC26,CC27,CC28,CC29,CC30,CC31,CC32,CC33,CC34,CC35,CC36,CC37,CC38" if thisfile=="A1.txt": if (allpart=="0"): #有外埔 ca5-mfr7.cm589.net 28ss #無外補 c39-4gb93.cw8889.net top009 #pos1.2b598.net #)"# #www.bb5858.net #ku01 #aa8888 #www.fpk357.com #wa.jar199.com #168aq text3="SELECT TOP(1000) 網址, 帳號, 密碼 ,備用網址 FROM 商客基本資料表 WHERE (上一層='0')"# and 網址='wa.jar199.com' and 帳號='168aq')" text4="SELECT TOP(1000) "+editim+" FROM 商客基本資料表 WHERE (上一層='0')"# and 網址='wa.jar199.com' and 帳號='168aq')" CA_SQL="SELECT TOP(1000) 網址, 帳號, 主帳號 ,備用網址 FROM 商客基本資料表 WHERE (上一層='1')"# and 網址='wa.jar199.com' and 帳號='168aq')" else: text3="SELECT TOP(1000) 網址, 帳號, 密碼 ,備用網址 FROM 商客資料暫存檔 WHERE (上一層='0')"# and 網址='wa.jar199.com' and 帳號='168aq')" text4="SELECT TOP(1000) "+editim+" FROM 商客基本資料表 WHERE (上一層='0')"# and 網址='wa.jar199.com' and 帳號='168aq')" CA_SQL="SELECT TOP(1000) 網址, 帳號, 主帳號 ,備用網址 FROM 商客資料暫存檔 WHERE (上一層='1')"# and 網址='wa.jar199.com' and 帳號='168aq')" elif thisfile=="A2.txt": if (allpart=="0"): text3="SELECT TOP(1000) 網址, 帳號, 密碼 ,備用網址 FROM 後台商客基本資料表 WHERE (上一層='0')"# and 網址='www.bb5858.net' and 帳號='c0000')" text4="SELECT TOP(1000) "+editim+" FROM 商客基本資料表 WHERE (上一層='0')"# and 網址='wa.jar199.com' and 帳號='168aq')" CA_SQL="SELECT TOP(1000) 網址, 帳號, 主帳號 ,備用網址 FROM 後台商客基本資料表 WHERE (上一層='1')"# and 網址='www.bb5858.net' and 帳號='c0000')" else: text3="SELECT TOP(1000) 網址, 帳號, 密碼 ,備用網址 FROM 後台商客資料暫存檔 WHERE (上一層='0')"# and 網址='www.bb5858.net' and 帳號='c0000')" text4="SELECT TOP(1000) "+editim+" FROM 商客基本資料表 WHERE (上一層='0')"# and 網址='wa.jar199.com' and 帳號='168aq')" CA_SQL="SELECT TOP(1000) 網址, 帳號, 主帳號 ,備用網址 FROM 後台商客資料暫存檔 WHERE (上一層='1')"# and 網址='www.bb5858.net' and 帳號='c0000')" loopper2=pd.read_sql(text3,engine3) childAdminLs=pd.read_sql(CA_SQL,engine3) loopper3=pd.read_sql(text4,engine3) contforloop=len(loopper2) loopper2=loopper2.values loopper3=loopper3.values childAdminLs=childAdminLs.values print(loopper2) print(len(loopper3[0])) if thisfile=="A2.txt": x=0 while x != len(loopper3[0]): loopper3[0][x] = True x+=1 print(loopper3) return contforloop,loopper2,childAdminLs,loopper3 except: traceback.print_exc() # 捕捉異常,並將異常傳播資訊輸出控制檯 traceback.print_exc(file=open('log.txt', 'a')) logging.debug('debug message',exc_info=True) logging.info('info message',exc_info=True) logging.warning('warning message',exc_info=True) logging.error('error message',exc_info=True) logging.critical('critical message',exc_info=True) app1 = QtWidgets.QApplication([]) error_dialog = QtWidgets.QErrorMessage() error_dialog.setWindowTitle('ERROR') error_dialog.showMessage('無基本資料') app1.exec_() def CreateLogEngine(): try: DB_session_log = sessionmaker(engine) db_session_log= DB_session_log() Log_database=db_session_log.query(Logdata).all() LogDbName=Log_database[0].資料庫 LogIPName=Log_database[0].IP位置 LogAdName=Log_database[0].帳號 LogPdName=Log_database[0].密碼 log_Engine=create_engine('mssql+pyodbc://'+LogAdName+':'+LogPdName+'@'+LogIPName+'/'+LogDbName+'?driver=SQL+Server+Native+Client+11.0') return log_Engine except: traceback.print_exc() # 捕捉異常,並將異常傳播資訊輸出控制檯 traceback.print_exc(file=open('log.txt', 'a')) logging.debug('debug message',exc_info=True) logging.info('info message',exc_info=True) logging.warning('warning message',exc_info=True) logging.error('error message',exc_info=True) logging.critical('critical message',exc_info=True) app1 = QtWidgets.QApplication([]) error_dialog = QtWidgets.QErrorMessage() error_dialog.setWindowTitle('ERROR') error_dialog.showMessage('記錄連線失敗') app1.exec_() def LongFirstLogin(urlkey,adminkey,passkey): try: #===========================================================網站需要的加密 print(urlkey) pubkey="B0C1D0E12B47DA93A24C7422D433170A4D5B126A27CED6F3087652723562889803E2280041F02E6B24A251C928EBE5BA12501D466D63A43AD5D88A5809A09271F14FD220C0DAE272CAAF9F1CF09DAF52005272529071723C0CB87B5A6392860CA2E72B23A4652910DB87BAC31D89E4DD23B3C56AAE685D9A14C4CC89862AAA27" rsaPublickey = int(pubkey,16) key = rsa.PublicKey(rsaPublickey,65537) message='{\"Account\":\"'+adminkey+'\",\"Password\":\"'+passkey+'\"}' message=message.encode('utf8') #passwd = rsa.encrypt(message,key) passwd = binascii.b2a_hex(rsa.encrypt(message,key)).decode() #========================================================================= Loginurl="http://"+urlkey+"/api/shared/login" headers1 = { 'Content-Length': '256', 'Content-Type': 'application/x-www-form-urlencoded' } response = requests.request("POST", Loginurl, headers=headers1, data=passwd, timeout=10,verify=False) return response except: response="無法取得資料" return response def LongSecondLogin(LFLresponse): try: LFLresponseJson=json.loads(LFLresponse.text) print("LFLresponseJson:"+str(LFLresponseJson)) SecondLoginUrl=LFLresponseJson['Redirect'] SecondLoginData=LFLresponseJson['Data'] headers2 = { 'Content-Length': '514', 'Content-Type': 'application/x-www-form-urlencoded' } print(SecondLoginUrl)#debug GatewayUrl="http:"+SecondLoginUrl print("GatewayUrl"+GatewayUrl) LoginGatewayPostData="+="+SecondLoginData response2 = requests.request("POST", GatewayUrl, headers=headers2, data=LoginGatewayPostData, timeout=10,verify=False) return SecondLoginUrl,SecondLoginData,response2 except: SecondLoginUrl="" SecondLoginData="" response2="" return SecondLoginUrl,SecondLoginData,response2 def LongGetData(urlkey, adminkey, passkey, startDatekey, endDatekey,backupUrl,childAdminLs): print("URLLLLLLLLLLLLLL:"+str(urlkey)) try: LFLresponse=LongFirstLogin(urlkey,adminkey,passkey)#第一層登入 if LFLresponse=="無法取得資料": urlkey=backupUrl#使用備用網址 LFLresponse=LongFirstLogin(urlkey,adminkey,passkey) if LFLresponse=="無法取得資料": fordebugger="無法取得資料" allll=pd.DataFrame() return allll,fordebugger,urlkey,adminkey if LFLresponse.status_code==200: SecondLoginUrl,SecondLoginData,LSLresponse=LongSecondLogin(LFLresponse)#第一層登入成功 登入第2層 if LSLresponse=="": print('我從這邊出去的') allll,fordebugger,urlkey,adminkey=ShortGetData(urlkey, adminkey, passkey, startDatekey, endDatekey,childAdminLs) #fordebugger="無法取得資料" #allll=pd.DataFrame() return allll,fordebugger,urlkey,adminkey else: getnameurl = "http:"+SecondLoginUrl[:-21]+"/Admin/D/D02" cookie=LSLresponse.cookies cookie=dict(cookie)['ASP.NET_SessionId'] print("cookie:"+str(cookie)) GetDataUrl="http:"+SecondLoginUrl[:-21]+"/api/AdminD02Report1/MainQuery"#-21=-(/Command/LoginGateway) cookstring="ASP.NET_SessionId="+cookie headers88 = { 'X-Requested-With': 'XMLHttpRequest', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36', 'Content-Type': 'application/x-www-form-urlencoded', 'Cookie': cookstring, } response4 = requests.request("GET", getnameurl, headers=headers88, timeout=10,verify=False) print(response4.status_code) if response4.status_code != 200: getnameurl = "http:"+SecondLoginUrl[:-21]+"/Front/A/A08" response4 = requests.request("GET", getnameurl, headers=headers88, timeout=10,verify=False) print(response4.status_code) #print("respons4444444"+response4.text) soup3=BeautifulSoup(response4.text,"lxml") pattern = re.compile(r'Name:"(.*?)"',re.MULTILINE|re.DOTALL) #print(pattern) script = soup3.find("script", text=pattern) #print("SCRIPTTTTT:::::"+str(script)) matches = re.finditer(r'Name:"(.*?)"', script.string, re.MULTILINE) matchend=[] badmatchend= ["單碰","配比包牌","雙面包牌","連碰","柱碰","一比四","套餐","連柱碰","雙星連碰柱","三星連碰柱","雙連碰","仟XXX","X佰XX","XX拾X","XXX個", "仟佰XX","仟X拾X","仟XX個","X佰拾X","X佰X個","XX拾個","仟佰拾X","仟佰X個","仟X拾個","X佰拾個","佰XX","X拾X","XX個","佰拾X","佰X個","X拾個"] for matchNum, match in enumerate(matches, start=1): #print ("在{start}-{end}找到匹配{matchNum}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group())) for groupNum in range(0, len(match.groups())): groupNum = groupNum + 1 if match.group(groupNum) not in matchend and match.group(groupNum) not in badmatchend: matchend.append(match.group(groupNum)) #print ("在{start}-{end}找到组{groupNum}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum))) write_csv(matchend,startDatekey,endDatekey,urlkey,adminkey,"101") print(matchend) print(loopper3) getData3 = "" if len(loopper3) > 0: if '迦納彩' in matchend and loopper3[0][37] == True: getData3 += "&GameType%5B%5D=35" #if '加州彩' in matchend and loopper3[0][34] == True: # getData3 += "&GameType%5B%5D=35" if '天天樂' in matchend and loopper3[0][6] == True: getData3 += "&GameType%5B%5D=22" if '威力' in matchend and loopper3[0][5] == True: getData3 += "&GameType%5B%5D=14" if '539' in matchend and loopper3[0][4] == True: getData3 += "&GameType%5B%5D=13" if '大樂' in matchend and loopper3[0][3] == True: getData3 += "&GameType%5B%5D=12" if '六合' in matchend and loopper3[0][2] == True: getData3 += "&GameType%5B%5D=11" if '三星彩' in matchend and loopper3[0][1] == True: getData3 += "&GameType%5B%5D=3" if '四星彩' in matchend and loopper3[0][0] == True: getData3 += "&GameType%5B%5D=2" if '十二不中' in matchend and loopper3[0][24] == True: getData3 += "&GroupType%5B%5D=160" if '十一不中' in matchend and loopper3[0][23] == True: getData3 += "&GroupType%5B%5D=159" if '十不中' in matchend and loopper3[0][22] == True: getData3 += "&GroupType%5B%5D=158" if '九不中' in matchend and loopper3[0][21] == True: getData3 += "&GroupType%5B%5D=157" if '八不中' in matchend and loopper3[0][20] == True: getData3 += "&GroupType%5B%5D=156" if '七不中' in matchend and loopper3[0][19] == True: getData3 += "&GroupType%5B%5D=155" if '六不中' in matchend and loopper3[0][18] == True: getData3 += "&GroupType%5B%5D=154" if '五不中' in matchend and loopper3[0][17] == True: getData3 += "&GroupType%5B%5D=153" if '五星' in matchend and loopper3[0][16] == True: getData3 += "&GroupType%5B%5D=118" if '天碰三' in matchend and loopper3[0][15] == True: getData3 += "&GroupType%5B%5D=109" if '天碰二' in matchend and loopper3[0][14] == True: getData3 += "&GroupType%5B%5D=108" if '四星' in matchend and loopper3[0][13] == True: getData3 += "&GroupType%5B%5D=107" if '三星' in matchend and loopper3[0][12] == True: getData3 += "&GroupType%5B%5D=106" if '二星' in matchend and loopper3[0][11] == True: getData3 += "&GroupType%5B%5D=105" if '特尾三' in matchend and loopper3[0][10] == True: getData3 += "&GroupType%5B%5D=104" if '台號' in matchend and loopper3[0][9] == True: getData3 += "&GroupType%5B%5D=103" if '特碼' in matchend and loopper3[0][8] == True: getData3 += "&GroupType%5B%5D=102" if '全車' in matchend and loopper3[0][7] == True: getData3 += "&GroupType%5B%5D=101" if '合單雙' in matchend and loopper3[0][33] == True: getData3 += "&GroupType%5B%5D=9" if '四字現' in matchend and loopper3[0][32] == True: getData3 += "&GroupType%5B%5D=8" if '三字現' in matchend and loopper3[0][31] == True: getData3 += "&GroupType%5B%5D=7" if '二字現' in matchend and loopper3[0][30] == True: getData3 += "&GroupType%5B%5D=6" if '一字現' in matchend and loopper3[0][29] == True: getData3 += "&GroupType%5B%5D=5" if '四定位' in matchend and loopper3[0][28] == True: getData3 += "&GroupType%5B%5D=4" if '三定位' in matchend and loopper3[0][27] == True: getData3 += "&GroupType%5B%5D=3" if '二定位' in matchend and loopper3[0][26] == True: getData3 += "&GroupType%5B%5D=2" if '一定位' in matchend and loopper3[0][25] == True: getData3 += "&GroupType%5B%5D=1" print(getData3) print(getData3.find("GameType")) getData= "Account="+getData3+"&StartDate="+startDatekey+"&EndDate="+endDatekey+"&IsNotShowNow=true"#FPK375#jnn688 #====================================種類================================= #getData="Account=&GameType%5B%5D=14&GameType%5B%5D=22&GameType%5B%5D=13&GameType%5B%5D=11&GameType%5B%5D=12&GroupType%5B%5D=160&GroupType%5B%5D=159&GroupType%5B%5D=158&GroupType%5B%5D=157&GroupType%5B%5D=156&GroupType%5B%5D=155&GroupType%5B%5D=154&GroupType%5B%5D=153&GroupType%5B%5D=118&GroupType%5B%5D=109&GroupType%5B%5D=108&GroupType%5B%5D=107&GroupType%5B%5D=106&GroupType%5B%5D=105&GroupType%5B%5D=104&GroupType%5B%5D=103&GroupType%5B%5D=102&GroupType%5B%5D=101&StartDate"+startDatekey+"&EndDate="+endDatekey+"&IsNotShowNow=true" #getData= "Account=&GameType%5B%5D=35&GameType%5B%5D=22&GameType%5B%5D=11&GameType%5B%5D=12&GameType%5B%5D=13&GroupType%5B%5D=118&GroupType%5B%5D=109&GroupType%5B%5D=108&GroupType%5B%5D=102&GroupType%5B%5D=160&GroupType%5B%5D=159&GroupType%5B%5D=158&GroupType%5B%5D=157&GroupType%5B%5D=156&GroupType%5B%5D=155&GroupType%5B%5D=154&GroupType%5B%5D=153&GroupType%5B%5D=107&GroupType%5B%5D=106&GroupType%5B%5D=105&GroupType%5B%5D=104&GroupType%5B%5D=103&GroupType%5B%5D=101&StartDate="+startDatekey+"&EndDate="+endDatekey+"&IsNotShowNow=true"#FPK375#jnn688 response3 = requests.request("POST", GetDataUrl, headers=headers88, data=getData, timeout=10,verify=False) if response3.status_code!=200: GetDataUrl="http:"+SecondLoginUrl[:-21]+"/api/FrontA08Report1/MainQuery"#-21=-(/Command/LoginGateway) response3 = requests.request("POST", GetDataUrl, headers=headers88, data=getData, timeout=10,verify=False) print(response3) print("AAAAA0") if response3.status_code==200: jsondata=json.loads(response3.text) print("AAAAA1") #print(jsondata) if response3.text=="null": getData= "Account=&GameType%5B%5D=14&GameType%5B%5D=22&GameType%5B%5D=11&GameType%5B%5D=12&GameType%5B%5D=13&GroupType%5B%5D=118&GroupType%5B%5D=109&GroupType%5B%5D=108&GroupType%5B%5D=102&GroupType%5B%5D=160&GroupType%5B%5D=159&GroupType%5B%5D=158&GroupType%5B%5D=157&GroupType%5B%5D=156&GroupType%5B%5D=155&GroupType%5B%5D=154&GroupType%5B%5D=153&GroupType%5B%5D=107&GroupType%5B%5D=106&GroupType%5B%5D=105&GroupType%5B%5D=104&GroupType%5B%5D=103&GroupType%5B%5D=101&StartDate="+startDatekey+"&EndDate="+endDatekey+"&IsNotShowNow=true"#FPK375#jnn688 response3 = requests.request("POST", GetDataUrl, headers=headers88, data=getData, timeout=10,verify=False) print("AAAAA7") if response3.text=="null": #getData= "Account=&GameType%5B%5D=14&GameType%5B%5D=22&GameType%5B%5D=13&GameType%5B%5D=11&GameType%5B%5D=12&GroupType%5B%5D=160&GroupType%5B%5D=159&GroupType%5B%5D=158&GroupType%5B%5D=157&GroupType%5B%5D=156&GroupType%5B%5D=155&GroupType%5B%5D=154&GroupType%5B%5D=153&GroupType%5B%5D=118&GroupType%5B%5D=109&GroupType%5B%5D=108&GroupType%5B%5D=107&GroupType%5B%5D=106&GroupType%5B%5D=105&GroupType%5B%5D=104&GroupType%5B%5D=103&GroupType%5B%5D=102&GroupType%5B%5D=101&StartDate"+startDatekey+"&EndDate="+endDatekey+"&IsNotShowNow=true" getData= "Account=&GameType%5B%5D=22&GameType%5B%5D=11&GameType%5B%5D=12&GameType%5B%5D=13&GroupType%5B%5D=118&GroupType%5B%5D=109&GroupType%5B%5D=108&GroupType%5B%5D=102&GroupType%5B%5D=160&GroupType%5B%5D=159&GroupType%5B%5D=158&GroupType%5B%5D=157&GroupType%5B%5D=156&GroupType%5B%5D=155&GroupType%5B%5D=154&GroupType%5B%5D=153&GroupType%5B%5D=107&GroupType%5B%5D=106&GroupType%5B%5D=105&GroupType%5B%5D=104&GroupType%5B%5D=103&GroupType%5B%5D=101&StartDate="+startDatekey+"&EndDate="+endDatekey+"&IsNotShowNow=true"#FPK375#jnn688 response3 = requests.request("POST", GetDataUrl, headers=headers88, data=getData, timeout=10,verify=False) print("AAAAA2") if response3.text=="null": #getData= "Account=&GameType%5B%5D=22&GameType%5B%5D=11&GameType%5B%5D=12&GameType%5B%5D=13&GroupType%5B%5D=118&GroupType%5B%5D=109&GroupType%5B%5D=108&GroupType%5B%5D=102&GroupType%5B%5D=160&GroupType%5B%5D=159&GroupType%5B%5D=158&GroupType%5B%5D=157&GroupType%5B%5D=156&GroupType%5B%5D=155&GroupType%5B%5D=154&GroupType%5B%5D=153&GroupType%5B%5D=107&GroupType%5B%5D=106&GroupType%5B%5D=105&GroupType%5B%5D=104&GroupType%5B%5D=103&GroupType%5B%5D=101&StartDate="+startDatekey+"&EndDate="+endDatekey+"&IsNotShowNow=true"#FPK375#jnn688 getData= "Account=&GameType%5B%5D=11&GameType%5B%5D=12&GameType%5B%5D=13&GroupType%5B%5D=109&GroupType%5B%5D=108&GroupType%5B%5D=102&GroupType%5B%5D=160&GroupType%5B%5D=159&GroupType%5B%5D=158&GroupType%5B%5D=157&GroupType%5B%5D=156&GroupType%5B%5D=155&GroupType%5B%5D=154&GroupType%5B%5D=153&GroupType%5B%5D=107&GroupType%5B%5D=106&GroupType%5B%5D=105&GroupType%5B%5D=104&GroupType%5B%5D=103&GroupType%5B%5D=101&StartDate="+startDatekey+"&EndDate="+endDatekey+"&IsNotShowNow=true"#FPK375#jnn688 response3 = requests.request("POST", GetDataUrl, headers=headers88, data=getData, timeout=10,verify=False) #responsetxt=response3.text #print(responsetxt) print("AAAAA3") if response3.text=="null": getData="Account=&GameType%5B%5D=22&GameType%5B%5D=13&GroupType%5B%5D=160&GroupType%5B%5D=159&GroupType%5B%5D=158&GroupType%5B%5D=157&GroupType%5B%5D=156&GroupType%5B%5D=155&GroupType%5B%5D=154&GroupType%5B%5D=153&GroupType%5B%5D=118&GroupType%5B%5D=107&GroupType%5B%5D=106&GroupType%5B%5D=105&GroupType%5B%5D=104&GroupType%5B%5D=103&GroupType%5B%5D=101&StartDate="+startDatekey+"&EndDate="+endDatekey+"&IsNotShowNow=true"#KPC365 response3 = requests.request("POST", GetDataUrl, headers=headers88, data=getData, timeout=10,verify=False) print("AAAAA4") if response3.text=="null": getData="Account=&GameType%5B%5D=13&GroupType%5B%5D=160&GroupType%5B%5D=159&GroupType%5B%5D=158&GroupType%5B%5D=157&GroupType%5B%5D=156&GroupType%5B%5D=155&GroupType%5B%5D=154&GroupType%5B%5D=153&GroupType%5B%5D=107&GroupType%5B%5D=106&GroupType%5B%5D=105&GroupType%5B%5D=104&GroupType%5B%5D=103&GroupType%5B%5D=101&StartDate="+startDatekey+"&EndDate="+endDatekey+"&IsNotShowNow=true" #UJK555 response3 = requests.request("POST", GetDataUrl, headers=headers88, data=getData, timeout=10,verify=False) print("AAAAA5") if response3.text=="null": #getData="Account=&GameType%5B%5D=22&GameType%5B%5D=11&GameType%5B%5D=12&GroupType%5B%5D=160&GroupType%5B%5D=159&GroupType%5B%5D=158&GroupType%5B%5D=157&GroupType%5B%5D=156&GroupType%5B%5D=155&GroupType%5B%5D=154&GroupType%5B%5D=153&GroupType%5B%5D=110&GroupType%5B%5D=109&GroupType%5B%5D=108&GroupType%5B%5D=107&GroupType%5B%5D=106&GroupType%5B%5D=105&GroupType%5B%5D=104&GroupType%5B%5D=103&GroupType%5B%5D=102&GroupType%5B%5D=101&StartDate="+startDatekey+"&EndDate="+endDatekey+"&IsNotShowNow=true" #UJK555 getData="Account="+getData3+"&StartDate="+startDatekey+"&EndDate="+endDatekey+"&IsNotShowNow=true" #UJK555 response3 = requests.request("POST", GetDataUrl, headers=headers88, data=getData, timeout=10,verify=False) print("AAAAA8") jsondata=json.loads(response3.text) #print(jsondata) print("AAAAA6") #====================================種類========================================= #====================================解析資料===================================== allll=[] if len(jsondata['DataList'])>0: #print(len(jsondata['DataList'])) #print(jsondata['DataList']) #print(jsondata['DataList'][0]['NickName']) for i in range(len(jsondata['DataList'])): allll.append([]) allll[i].append(jsondata['DataList'][i]['NickName']+"("+jsondata['DataList'][i]['Account']+")") allll[i].append(jsondata['DataList'][i]['TotBet']) allll[i].append(jsondata['DataList'][i]['TotBetRebate']) allll[i].append(jsondata['DataList'][i]['TotBetWinLose']) allll[i].append(jsondata['DataList'][i]['SubtotalTotWinLose']) for j in range(len(jsondata['DataList'][i]['ContributionPaid'])): allll[i].append(jsondata['DataList'][i]['ContributionPaid'][j]['TotPaid']) if len(jsondata['DataList'][i]['ContributionPaid'])<7: ReAdd=7-len(jsondata['DataList'][i]['ContributionPaid']) for z in range(ReAdd): allll[i].append(None) allll[i].append(jsondata['DataList'][i]['SubtotalTotDutyWinLose']) allll[i].append(jsondata['DataList'][i]['SubtotalRebateWinLoseDifference']) allll[i].append(jsondata['DataList'][i]['TotPaid']) allll[i].append(jsondata['DataList'][i]['SubtotalSelfTotWinLose']) try: allll[i].append(jsondata['DataList'][i]['PaidContributor']) except: allll[i].append(None) allll[i].append(jsondata['DataList'][i]['TotContribution']) allll[i].append(jsondata['DataList'][i]['SubtotalContribution']) try: allll[i].append(jsondata['DataList'][i]['TotControl']) except: allll[i].append(None) try: allll[i].append(jsondata['DataList'][i]['TotControlDuty']) except: allll[i].append(None) try: allll[i].append(jsondata['DataList'][i]['SystemDuty']) except: allll[i].append(None) print(allll) allll=pd.DataFrame(allll) allll.columns =["名稱","總量","退水","中獎","輸贏","會員","代理","總代理","股東","大股東","總監","大總監","佔成輸贏","水倍差","上繳金額","自已總輸贏","上繳貢獻額","貢獻額","貢獻度","調盤退水","調退實佔","系統商"] fordebugger="OK" else: allll=pd.DataFrame() fordebugger="查詢期間無資料" #=================================解析資料============================================= #================================插入資訊============================================== WEBURLTXT=[] ADMINTXT=[] StartDATETXT=[] EndDATETXT=[] TIMERAND=[] nowTime=datetime.datetime.now().strftime("%m%d%H%M%S") randomNum=random.randint(0,10000); if randomNum<10: randomNum=str(0)+str(0)+str(0)+str(randomNum) elif randomNum>10 and randomNum<100: randomNum=str(0)+str(0)+str(randomNum) elif randomNum>100 and randomNum<1000: randomNum=str(0)+str(randomNum) uniqueNum=str(nowTime)+str(randomNum) for i in range(len(allll)): WEBURLTXT.append(urlkey) ADMINTXT.append(adminkey) StartDATETXT.append(startDatekey) EndDATETXT.append(endDatekey) TIMERAND.append(None) allll.insert(0,"開始日期",StartDATETXT) allll.insert(1,"結束日期",EndDATETXT) allll.insert(2,"網址",WEBURLTXT) allll.insert(3,"帳戶",ADMINTXT) allll.insert(4,"隨機碼",TIMERAND) print(allll) #===================================================================================== refind=pd.DataFrame(columns =["開始日期","結束日期","網址","帳戶","名稱","總量","退水","中獎","輸贏","佔成輸贏","水倍差","上繳金額","自已總輸贏","上繳貢獻額","貢獻額","貢獻度","下注明細","玩法明細","調盤退水","調退實佔","上繳","會員","代理","總代理","股東","大股東","總監","大總監","系統商","隨機碼"]) #refind=pd.DataFrame(columns =["開始日期","結束日期","網址","帳戶","名稱","總量","退水","中獎","輸贏","佔成輸贏","水倍差","上繳金額","自已總輸贏","上繳貢獻額","貢獻額","貢獻度","下注明細","玩法明細","調盤退水","調退實佔","上繳","會員","代理","總代理","股東","大股東","總監","隨機碼"]) allll=pd.concat([refind,allll],ignore_index = True) end = time.time() print("執行時間:%f 秒" % (end - start)) #子帳號 #======================================================================================== doneChild=pd.DataFrame(columns =["開始日期","結束日期","網址","帳戶","名稱","總量","退水","中獎","輸贏","佔成輸贏","水倍差","上繳金額","自已總輸贏","上繳貢獻額","貢獻額","貢獻度","下注明細","玩法明細","調盤退水","調退實佔","上繳","會員","代理","總代理","股東","大股東","總監","大總監","系統商","隨機碼"]) print("childAdminLschildAdminLs:"+str(len(childAdminLs))) for i in range(len(childAdminLs)): childallll=pd.DataFrame() if (urlkey==childAdminLs[i][0] or urlkey==childAdminLs[i][3]) and adminkey== childAdminLs[i][2]: childAdmin=childAdminLs[i][1] print(childAdmin) getData= "Account="+childAdminLs[i][1]+getData3+"&StartDate="+startDatekey+"&EndDate="+endDatekey+"&IsNotShowNow=true"#FPK375#jnn688 #getData= "Account="+childAdminLs[i][1]+"&GameType%5B%5D=35&GameType%5B%5D=22&GameType%5B%5D=11&GameType%5B%5D=12&GameType%5B%5D=13&GroupType%5B%5D=118&GroupType%5B%5D=109&GroupType%5B%5D=108&GroupType%5B%5D=102&GroupType%5B%5D=160&GroupType%5B%5D=159&GroupType%5B%5D=158&GroupType%5B%5D=157&GroupType%5B%5D=156&GroupType%5B%5D=155&GroupType%5B%5D=154&GroupType%5B%5D=153&GroupType%5B%5D=107&GroupType%5B%5D=106&GroupType%5B%5D=105&GroupType%5B%5D=104&GroupType%5B%5D=103&GroupType%5B%5D=101&StartDate="+startDatekey+"&EndDate="+endDatekey+"&IsNotShowNow=true"#FPK375#jnn688 response3child = requests.request("POST", GetDataUrl, headers=headers88, data=getData, timeout=10,verify=False) jsondata=json.loads(response3child.text) print("chiAAAAA12") #print(jsondata) if response3child.text=="null": getData= "Account="+childAdmin+"&GameType%5B%5D=14&GameType%5B%5D=22&GameType%5B%5D=13&GameType%5B%5D=11&GameType%5B%5D=12&GroupType%5B%5D=118&GroupType%5B%5D=109&GroupType%5B%5D=108&GroupType%5B%5D=102&GroupType%5B%5D=160&GroupType%5B%5D=159&GroupType%5B%5D=158&GroupType%5B%5D=157&GroupType%5B%5D=156&GroupType%5B%5D=155&GroupType%5B%5D=154&GroupType%5B%5D=153&GroupType%5B%5D=107&GroupType%5B%5D=106&GroupType%5B%5D=105&GroupType%5B%5D=104&GroupType%5B%5D=103&GroupType%5B%5D=101&StartDate="+startDatekey+"&EndDate="+endDatekey+"&IsNotShowNow=true"#FPK375#jnn688 response3child = requests.request("POST", GetDataUrl, headers=headers88, data=getData, timeout=10,verify=False) print("chiAAAAA13") if response3child.text=="null": getData= "Account="+childAdmin+"&GameType%5B%5D=22&GameType%5B%5D=11&GameType%5B%5D=12&GameType%5B%5D=13&GroupType%5B%5D=118&GroupType%5B%5D=109&GroupType%5B%5D=108&GroupType%5B%5D=102&GroupType%5B%5D=160&GroupType%5B%5D=159&GroupType%5B%5D=158&GroupType%5B%5D=157&GroupType%5B%5D=156&GroupType%5B%5D=155&GroupType%5B%5D=154&GroupType%5B%5D=153&GroupType%5B%5D=107&GroupType%5B%5D=106&GroupType%5B%5D=105&GroupType%5B%5D=104&GroupType%5B%5D=103&GroupType%5B%5D=101&StartDate="+startDatekey+"&EndDate="+endDatekey+"&IsNotShowNow=true"#FPK375#jnn688 response3child = requests.request("POST", GetDataUrl, headers=headers88, data=getData, timeout=10,verify=False) print("chiAAAAA8") if response3child.text=="null": #getData= "Account=&GameType%5B%5D=22&GameType%5B%5D=11&GameType%5B%5D=12&GameType%5B%5D=13&GroupType%5B%5D=118&GroupType%5B%5D=109&GroupType%5B%5D=108&GroupType%5B%5D=102&GroupType%5B%5D=160&GroupType%5B%5D=159&GroupType%5B%5D=158&GroupType%5B%5D=157&GroupType%5B%5D=156&GroupType%5B%5D=155&GroupType%5B%5D=154&GroupType%5B%5D=153&GroupType%5B%5D=107&GroupType%5B%5D=106&GroupType%5B%5D=105&GroupType%5B%5D=104&GroupType%5B%5D=103&GroupType%5B%5D=101&StartDate="+startDatekey+"&EndDate="+endDatekey+"&IsNotShowNow=true"#FPK375#jnn688 getData= "Account="+childAdmin+"&GameType%5B%5D=11&GameType%5B%5D=12&GameType%5B%5D=13&GroupType%5B%5D=109&GroupType%5B%5D=108&GroupType%5B%5D=102&GroupType%5B%5D=160&GroupType%5B%5D=159&GroupType%5B%5D=158&GroupType%5B%5D=157&GroupType%5B%5D=156&GroupType%5B%5D=155&GroupType%5B%5D=154&GroupType%5B%5D=153&GroupType%5B%5D=107&GroupType%5B%5D=106&GroupType%5B%5D=105&GroupType%5B%5D=104&GroupType%5B%5D=103&GroupType%5B%5D=101&StartDate="+startDatekey+"&EndDate="+endDatekey+"&IsNotShowNow=true"#FPK375#jnn688 response3child = requests.request("POST", GetDataUrl, headers=headers88, data=getData, timeout=10,verify=False) print("chiAAAAA9") if response3child.text=="null": getData="Account="+childAdmin+"&GameType%5B%5D=22&GameType%5B%5D=13&GroupType%5B%5D=160&GroupType%5B%5D=159&GroupType%5B%5D=158&GroupType%5B%5D=157&GroupType%5B%5D=156&GroupType%5B%5D=155&GroupType%5B%5D=154&GroupType%5B%5D=153&GroupType%5B%5D=118&GroupType%5B%5D=107&GroupType%5B%5D=106&GroupType%5B%5D=105&GroupType%5B%5D=104&GroupType%5B%5D=103&GroupType%5B%5D=101&StartDate="+startDatekey+"&EndDate="+endDatekey+"&IsNotShowNow=true"#KPC365 response3child = requests.request("POST", GetDataUrl, headers=headers88, data=getData, timeout=10,verify=False) print("chiAAAAA10") if response3child.text=="null": getData="Account="+childAdmin+"&GameType%5B%5D=13&GroupType%5B%5D=160&GroupType%5B%5D=159&GroupType%5B%5D=158&GroupType%5B%5D=157&GroupType%5B%5D=156&GroupType%5B%5D=155&GroupType%5B%5D=154&GroupType%5B%5D=153&GroupType%5B%5D=107&GroupType%5B%5D=106&GroupType%5B%5D=105&GroupType%5B%5D=104&GroupType%5B%5D=103&GroupType%5B%5D=101&StartDate="+startDatekey+"&EndDate="+endDatekey+"&IsNotShowNow=true" #UJK555 response3child = requests.request("POST", GetDataUrl, headers=headers88, data=getData, timeout=10,verify=False) print("chiAAAAA11") if response3child.text=="null": getData="Account="+childAdmin+"&GameType%5B%5D=22&GameType%5B%5D=11&GameType%5B%5D=12&GroupType%5B%5D=160&GroupType%5B%5D=159&GroupType%5B%5D=158&GroupType%5B%5D=157&GroupType%5B%5D=156&GroupType%5B%5D=155&GroupType%5B%5D=154&GroupType%5B%5D=153&GroupType%5B%5D=110&GroupType%5B%5D=109&GroupType%5B%5D=108&GroupType%5B%5D=107&GroupType%5B%5D=106&GroupType%5B%5D=105&GroupType%5B%5D=104&GroupType%5B%5D=103&GroupType%5B%5D=102&GroupType%5B%5D=101&StartDate="+startDatekey+"&EndDate="+endDatekey+"&IsNotShowNow=true" #UJK555 response3child = requests.request("POST", GetDataUrl, headers=headers88, data=getData, timeout=10,verify=False) print("chiAAAAA14") jsondata=json.loads(response3child.text) print(jsondata) childallll=[] if len(jsondata['DataList'])>0: for i in range(len(jsondata['DataList'])): childallll.append([]) childallll[i].append(jsondata['DataList'][i]['NickName']+"("+jsondata['DataList'][i]['Account']+")") # childallll[i].append(jsondata['DataList'][i]['TotBet']) childallll[i].append(jsondata['DataList'][i]['TotBetRebate']) childallll[i].append(jsondata['DataList'][i]['TotBetWinLose']) childallll[i].append(jsondata['DataList'][i]['SubtotalTotWinLose']) for j in range(len(jsondata['DataList'][i]['ContributionPaid'])): childallll[i].append(jsondata['DataList'][i]['ContributionPaid'][j]['TotPaid']) if len(jsondata['DataList'][i]['ContributionPaid'])<7: ReAdd=7-len(jsondata['DataList'][i]['ContributionPaid']) for z in range(ReAdd): childallll[i].append(None) childallll[i].append(jsondata['DataList'][i]['SubtotalTotDutyWinLose']) childallll[i].append(jsondata['DataList'][i]['SubtotalRebateWinLoseDifference']) childallll[i].append(jsondata['DataList'][i]['TotPaid']) childallll[i].append(jsondata['DataList'][i]['SubtotalSelfTotWinLose']) childallll[i].append(jsondata['DataList'][i]['PaidContributor']) childallll[i].append(jsondata['DataList'][i]['TotContribution']) childallll[i].append(jsondata['DataList'][i]['SubtotalContribution']) childallll[i].append(jsondata['DataList'][i]['TotControl']) childallll[i].append(jsondata['DataList'][i]['TotControlDuty']) childallll[i].append(jsondata['DataList'][i]['SystemDuty']) print(childallll) childallll=pd.DataFrame(childallll) childallll.columns =["名稱","總量","退水","中獎","輸贏","會員","代理","總代理","股東","大股東","總監","大總監","佔成輸贏","水倍差","上繳金額","自已總輸贏","上繳貢獻額","貢獻額","貢獻度","調盤退水","調退實佔","系統商"] fordebugger="OK" else: childallll=pd.DataFrame() fordebugger="查詢期間無資料" print("FA:SSSAEL") WEBURLTXT=[] ADMINTXT=[] StartDATETXT=[] EndDATETXT=[] TIMERAND=[] nowTime=datetime.datetime.now().strftime("%m%d%H%M%S") randomNum=random.randint(0,10000); if randomNum<10: randomNum=str(0)+str(0)+str(0)+str(randomNum) elif randomNum>10 and randomNum<100: randomNum=str(0)+str(0)+str(randomNum) elif randomNum>100 and randomNum<1000: randomNum=str(0)+str(randomNum) uniqueNum=str(nowTime)+str(randomNum) for i in range(len(childallll)): WEBURLTXT.append(urlkey) ADMINTXT.append(childAdmin) StartDATETXT.append(startDatekey) EndDATETXT.append(endDatekey) TIMERAND.append(None) childallll.insert(0,"開始日期",StartDATETXT) childallll.insert(1,"結束日期",EndDATETXT) childallll.insert(2,"網址",WEBURLTXT) childallll.insert(3,"帳戶",ADMINTXT) childallll.insert(4,"隨機碼",TIMERAND) print(childallll) #===================================================================================== refind=pd.DataFrame(columns =["開始日期","結束日期","網址","帳戶","名稱","總量","退水","中獎","輸贏","佔成輸贏","水倍差","上繳金額","自已總輸贏","上繳貢獻額","貢獻額","貢獻度","下注明細","玩法明細","調盤退水","調退實佔","上繳","會員","代理","總代理","股東","大股東","總監","大總監","系統商","隨機碼"]) #refind=pd.DataFrame(columns =["開始日期","結束日期","網址","帳戶","名稱","總量","退水","中獎","輸贏","佔成輸贏","水倍差","上繳金額","自已總輸贏","上繳貢獻額","貢獻額","貢獻度","下注明細","玩法明細","調盤退水","調退實佔","上繳","會員","代理","總代理","股東","大股東","總監","隨機碼"]) childallll=pd.concat([refind,childallll],ignore_index = True) doneChild=pd.concat([refind,doneChild,childallll],ignore_index = True) #子帳號======================================================================================== allll=pd.concat([refind,allll,doneChild],ignore_index = True) return allll,fordebugger,urlkey,adminkey print(getData3.find("GameType")) if response3.status_code!=200 and getData3.find("GameType") != -1: fordebugger="無法取得資料" allll=pd.DataFrame() return allll,fordebugger,urlkey,adminkey elif response3.status_code!=200 and getData3.find("GameType") == -1: fordebugger="查詢期間無資料" allll=pd.DataFrame() return allll,fordebugger,urlkey,adminkey else: fordebugger="查詢期間無資料" allll=pd.DataFrame() return allll,fordebugger,urlkey,adminkey if LFLresponse.status_code!=200 : allll,fordebugger,urlkey,adminkey=ShortGetData(urlkey, adminkey, passkey, startDatekey, endDatekey,childAdminLs) #print(allll) return allll,fordebugger,urlkey,adminkey except: fordebugger="無法取得資料" print("errorcode4") allll=pd.DataFrame() return allll,fordebugger,urlkey,adminkey def ShortGetData(urlkey, adminkey, passkey, startDatekey, endDatekey,childAdminLs): print("我有進ShortGetData") badmatchend= ["單碰","配比包牌","雙面包牌","連碰","柱碰","一比四","套餐","連柱碰","雙星連碰柱","三星連碰柱","雙連碰","仟XXX","X佰XX","XX拾X","XXX個","全選", "仟佰XX","仟X拾X","仟XX個","X佰拾X","X佰X個","XX拾個","仟佰拾X","仟佰X個","仟X拾個","X佰拾個","佰XX","X拾X","XX個","佰拾X","佰X個","X拾個"] try: sloginUrl = "https://"+urlkey+"/pub/SuperGateway.php?c=900%2C"+adminkey+"%2C"+passkey response = requests.request("POST", sloginUrl, timeout=10,verify=False) #jsondata=json.loads(response.text) #SIDKey=rrr[2] print(response.status_code) if response.status_code==200:#如果網站有正常回應 if len(response.text)>3:#回應的是正確值 SIDKey=response.text.split(',')[2]#拆分SIDKey if len(SIDKey)<5:#如果SIDKey<拆分SIDKey SIDKey=response.text.split(',')[3] print(SIDKey) AMKey=SIDKey.split('_')[0] print(AMKey) LevelUrl="https://"+urlkey+"/hp/headmenu.php?si="+SIDKey LevelUrlresponse = requests.request("GET", LevelUrl, timeout=10,verify=False) print(LevelUrlresponse.status_code) #print(LevelUrlresponse.text) soup=BeautifulSoup(LevelUrlresponse.text,"lxml") #print(len(LevelUrlresponse.text)) #print("RESPONE:"+LevelUrlresponse.text) #print(soup) if len(LevelUrlresponse.text)>1:#一般種類 #---------------------尋找level------------------------- try: pattern = re.compile(r'var lv(.*?)=(.*?);',re.MULTILINE|re.DOTALL ) #print(pattern) script = soup.find("script", text=pattern) #print(script) print((len(pattern.search(script.string).group()))) if len(pattern.search(script.string).group())==11: Level=pattern.search(script.string).group(2)[1:] elif len(pattern.search(script.string).group())==9: Level=pattern.search(script.string).group(2) #print(pattern.search(script.string).group()) print("LEVELLLLL::::::::"+str(Level)) geeetURL="https://"+urlkey+"/func/report/rpt_plus.php?sid="+SIDKey+"&am="+AMKey+"$l="+Level print(geeetURL) editUrlresponse = requests.request("GET", geeetURL, timeout=10,verify=False) soup4=BeautifulSoup(editUrlresponse.text,"lxml") #print(type(str(soup4))) matches = re.finditer(r'/>(.+\w)\s', str(soup4), re.MULTILINE) matchend=[] for matchNum, match in enumerate(matches, start=1): #print ("在{start}-{end}找到匹配{matchNum}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group())) for groupNum in range(0, len(match.groups())): groupNum = groupNum + 1 matchtext = match.group(groupNum).strip() #print("mat111"+matchtext) if matchtext == '加州彩': matchtext = '加洲彩' #print("mat222"+matchtext) if matchtext not in matchend and matchtext not in badmatchend: matchend.append(matchtext) #print ("在{start}-{end}找到组{groupNum}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum))) write_csv(matchend,startDatekey,endDatekey,urlkey,adminkey,"365") print(matchend) print(loopper3) print(len(matchend)) getData3=Getdata(matchend) #print(matchend[1]) #print(cclist.index(matchend[1])) #print(loopper3[0][cclist.index(matchend[1])]) #print("GERDATAAAAA3:"+getData3) #print(pattern.search(script.string).group(1)) #Level=pattern.search(script.string).group(1) #---------------------尋找level------------------------- payload='sacco=&data1='+startDatekey+'&data2='+endDatekey+getData3+'&am='+AMKey+'&l='+Level+'&sid='+SIDKey+'&master=%20&Submit=%25E7%25A2%25BA%25E5%25AE%259A' iscommon=1 except Exception as e: print(e) #一般商品種類 else: geeetURL="https://"+urlkey+"/func/report/rpt_plus.php?sid="+SIDKey print(geeetURL) editUrlresponse = requests.request("GET", geeetURL, timeout=10,verify=False) soup4=BeautifulSoup(editUrlresponse.text,"lxml") #print(soup4) matches = re.finditer(r'/>(.+\w)\s', str(soup4), re.MULTILINE) matchend=[] for matchNum, match in enumerate(matches, start=1): #print ("在{start}-{end}找到匹配{matchNum}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group())) for groupNum in range(0, len(match.groups())): groupNum = groupNum + 1 matchtext = match.group(groupNum).strip() #print("mat11"+matchtext) if matchtext == "加州彩": matchtext = "加洲彩" #print("mat22"+matchtext) if matchtext not in matchend and matchtext not in badmatchend: matchend.append(matchtext) #print ("在{start}-{end}找到组{groupNum}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum))) write_csv(matchend,startDatekey,endDatekey,urlkey,adminkey,"365") print(matchend) print(loopper3) print(len(matchend)) getData3=Getdata(matchend) payload='sacco=&data1='+startDatekey+'&data2='+endDatekey+getData3+'&l=&sid='+SIDKey+'&master=yes&am=' #print(payload) iscommon=0 #後台用商品種類 GetUrl="https://"+urlkey+"/func/report/rpt_allplus.php" GetHeaders = { 'Content-Type': 'application/x-www-form-urlencoded' } GetResponse = requests.request("POST", GetUrl, headers=GetHeaders, data=payload, timeout=10,verify=False) print(GetResponse.status_code) #print(GetResponse.text) if GetResponse.text == "您所搜尋的日期範圍並無任何期數喔" : val=pd.DataFrame() fordebugger="查詢期間無資料" else: #向網站取得資料 val=pd.DataFrame(pd.read_html(GetResponse.text)[2])[:-1] print(len(val)) if len(val)>0:#是否有資料 val.columns = val.loc[0].values.tolist() val=val.drop([0]) print(val) #================將資訊插入資料================================= WEBURLTXT=[] ADMINTXT=[] StartDATETXT=[] EndDATETXT=[] TIMERAND=[] nowTime=datetime.datetime.now().strftime("%m%d%H%M%S") randomNum=random.randint(0,10000) if randomNum<10: randomNum=str(0)+str(0)+str(0)+str(randomNum) elif randomNum>10 and randomNum<100: randomNum=str(0)+str(0)+str(randomNum) elif randomNum>100 and randomNum<1000: randomNum=str(0)+str(randomNum) uniqueNum=str(nowTime)+str(randomNum) for i in range(len(val)): WEBURLTXT.append(urlkey) ADMINTXT.append(adminkey) StartDATETXT.append(startDatekey) EndDATETXT.append(endDatekey) TIMERAND.append(None) val.insert(0,"開始日期",StartDATETXT) val.insert(1,"結束日期",EndDATETXT) val.insert(2,"網址",WEBURLTXT) val.insert(3,"帳戶",ADMINTXT) val.insert(4,"隨機碼",TIMERAND) #====================================================== # refind=pd.DataFrame(columns =["開始日期","結束日期","網址","帳戶","客戶","總量","中獎","輸贏","客戶小計","代理小計","總代理小計","股東小計","大股東小計","總監小計","個人所得","水差","下注明細","查看對帳","隨機碼"]) refind=pd.DataFrame(columns =["開始日期","結束日期","網址","帳戶","客戶","總量","中獎","輸贏","客戶小計","代理小計","總代理小計","股東小計","大股東小計","總監小計","個人所得","水差","下注明細","查看對帳","貢獻額","貢獻度","調盤退水","調退實佔","隨機碼"]) #重整資料用 val=pd.concat([refind,val],ignore_index = True) #========================================================= if len(val)>0:#如果有資料 val.columns =["開始日期","結束日期","網址","帳戶","客戶s","總量s","中獎s","輸贏s","客戶小計s","代理小計s","總代理小計s","股東小計s","大股東小計s","總監小計s","個人所得s","水差s","下注明細s","查看對帳s","貢獻額s","貢獻度s","調盤退水s","調退實佔s","隨機碼"] # val.columns =["開始日期","結束日期","網址","帳戶","客戶s","總量s","中獎s","輸贏s","客戶小計s","代理小計s","總代理小計s","股東小計s","大股東小計s","總監小計s","個人所得s","水差s","下注明細s","查看對帳s","隨機碼"] fordebugger="OK" else: val=pd.DataFrame() fordebugger="查詢期間無資料" #======================================================== #=================子帳號======================================= doneChildval=pd.DataFrame(columns =["開始日期","結束日期","網址","帳戶","客戶s","總量s","中獎s","輸贏s","客戶小計s","代理小計s","總代理小計s","股東小計s","大股東小計s","總監小計s","個人所得s","水差s","下注明細s","查看對帳s","貢獻額s","貢獻度s","調盤退水s","調退實佔s","隨機碼"]) for i in range(len(childAdminLs)): childval=pd.DataFrame() if (urlkey==childAdminLs[i][0]or urlkey==childAdminLs[i][3])and adminkey== childAdminLs[i][2]: childAdmin=childAdminLs[i][1] if iscommon==1: payload='sacco='+childAdmin+'&data1='+startDatekey+'&data2='+endDatekey+getData3+'&am='+AMKey+'&l='+Level+'&sid='+SIDKey+'&master=%20&Submit=%25E7%25A2%25BA%25E5%25AE%259A' elif iscommon==0: payload='sacco='+childAdmin+'&data1='+startDatekey+'&data2='+endDatekey+getData3+'&l=&sid='+SIDKey+'&master=yes&am=' GetResponse = requests.request("POST", GetUrl, headers=GetHeaders, data=payload, timeout=10,verify=False) childval=pd.DataFrame(pd.read_html(GetResponse.text)[2])[:-1] if len(childval)>0:#是否有資料 childval.columns = childval.loc[0].values.tolist() childval=childval.drop([0]) print(childval) #================將資訊插入資料================================= WEBURLTXT=[] ADMINTXT=[] StartDATETXT=[] EndDATETXT=[] TIMERAND=[] nowTime=datetime.datetime.now().strftime("%m%d%H%M%S") randomNum=random.randint(0,10000); if randomNum<10: randomNum=str(0)+str(0)+str(0)+str(randomNum) elif randomNum>10 and randomNum<100: randomNum=str(0)+str(0)+str(randomNum) elif randomNum>100 and randomNum<1000: randomNum=str(0)+str(randomNum) uniqueNum=str(nowTime)+str(randomNum) for i in range(len(childval)): WEBURLTXT.append(urlkey) ADMINTXT.append(childAdmin) StartDATETXT.append(startDatekey) EndDATETXT.append(endDatekey) TIMERAND.append(None) childval.insert(0,"開始日期",StartDATETXT) childval.insert(1,"結束日期",EndDATETXT) childval.insert(2,"網址",WEBURLTXT) childval.insert(3,"帳戶",ADMINTXT) childval.insert(4,"隨機碼",TIMERAND) refind=pd.DataFrame(columns =["開始日期","結束日期","網址","帳戶","客戶","總量","中獎","輸贏","客戶小計","代理小計","總代理小計","股東小計","大股東小計","總監小計","個人所得","水差","下注明細","查看對帳","貢獻額","貢獻度","調盤退水","調退實佔","隨機碼"]) #重整資料用 childval=pd.concat([refind,childval],ignore_index = True) if len(childval)>0:#如果有資料 childval.columns =["開始日期","結束日期","網址","帳戶","客戶s","總量s","中獎s","輸贏s","客戶小計s","代理小計s","總代理小計s","股東小計s","大股東小計s","總監小計s","個人所得s","水差s","下注明細s","查看對帳s","貢獻額s","貢獻度s","調盤退水s","調退實佔s","隨機碼"] fordebugger="OK" else: childval=pd.DataFrame() fordebugger="查詢期間無資料" if GetResponse.text == "您所搜尋的日期範圍並無任何期數喔" : childval=pd.DataFrame() fordebugger="查詢期間無資料" doneChildval=pd.concat([doneChildval,childval],ignore_index = True) #======================================================== val=pd.concat([val,doneChildval],ignore_index = True) return val,fordebugger,urlkey,adminkey else: val=pd.DataFrame() print("error 1") fordebugger="無法取得資料" return val,fordebugger,urlkey,adminkey if response.status_code!=200: val=pd.DataFrame() print("error 2") fordebugger="無法取得資料" return val,fordebugger,urlkey,adminkey except: val=pd.DataFrame() print("error 3") fordebugger="無法取得資料" return val,fordebugger,urlkey,adminkey def write_csv(matchend,startDatekey,endDatekey,urlkey,adminkey,foods): deeptitle = copy.deepcopy(matchend) deeptitle.insert(0,foods) deeptitle.insert(1,startDatekey) deeptitle.insert(2,endDatekey) deeptitle.insert(3,urlkey) deeptitle.insert(4,adminkey) print("WRITETOCSV:"+str(deeptitle)) path="./webtitle.csv" with open(path,'a+',newline='',encoding='utf-8-sig') as f: csv_write = csv.writer(f) csv_write.writerow(deeptitle) print("WRITETOCSVEND") del deeptitle[0:5] def Getdata(matchend): cclist=["四星彩","三星彩","六合","大樂","539","威力","天天樂","全車","特碼","台號","特尾三","二星","三星","四星","天碰二","天碰三","五星","五不中","六不中","七不中","八不中","九不中", "十不中","十一不中","十二不中","一定位","二定位","三定位","四定位","一字現","二字現","三字現","四字現","合單雙","加洲彩","雙面","反轉樂","迦納彩"] getData3="" if len(matchend) == 15 : if matchend[0] in cclist and loopper3[0][cclist.index(matchend[0])] == True: getData3 += "&check0=yes" if matchend[1] in cclist and loopper3[0][cclist.index(matchend[1])] == True: getData3 += "&check1=yes" if matchend[2] in cclist and loopper3[0][cclist.index(matchend[2])] == True: getData3 += "&check2=yes" if matchend[3] in cclist and loopper3[0][cclist.index(matchend[3])] == True: getData3 += "&check3=yes" if matchend[4] in cclist and loopper3[0][cclist.index(matchend[4])] == True: getData3 += "&check4=yes" if matchend[5] in cclist and loopper3[0][cclist.index(matchend[5])] == True: getData3 += "&check5=yes" if matchend[6] in cclist and loopper3[0][cclist.index(matchend[6])] == True: getData3 += "&check6=yes" if matchend[7] in cclist and loopper3[0][cclist.index(matchend[7])] == True: getData3 += "&check7=yes" if matchend[8] in cclist and loopper3[0][cclist.index(matchend[8])] == True: getData3 += "&check8=yes" if matchend[9] in cclist and loopper3[0][cclist.index(matchend[9])] == True: getData3 += "&check9=yes" if matchend[10] in cclist and loopper3[0][cclist.index(matchend[10])] == True: getData3 += "&check10=yes" if matchend[11] in cclist and loopper3[0][cclist.index(matchend[11])] == True: getData3 += "&check11=yes" if matchend[12] in cclist and loopper3[0][cclist.index(matchend[12])] == True: getData3 += "&cas1=yes" if matchend[13] in cclist and loopper3[0][cclist.index(matchend[13])] == True: getData3 += "&cas2=yes" if matchend[14] in cclist and loopper3[0][cclist.index(matchend[14])] == True: getData3 += "&cas3=yes" elif len(matchend) == 16: print(matchend[0]) print(loopper3[0][cclist.index(matchend[0])]) if matchend[0] in cclist and loopper3[0][cclist.index(matchend[0])] == True: getData3 += "&check0=yes" if matchend[1] in cclist and loopper3[0][cclist.index(matchend[1])] == True: getData3 += "&check1=yes" if matchend[2] in cclist and loopper3[0][cclist.index(matchend[2])] == True: getData3 += "&check2=yes" if matchend[3] in cclist and loopper3[0][cclist.index(matchend[3])] == True: getData3 += "&check3=yes" if matchend[4] in cclist and loopper3[0][cclist.index(matchend[4])] == True: getData3 += "&check4=yes" if matchend[5] in cclist and loopper3[0][cclist.index(matchend[5])] == True: getData3 += "&check5=yes" if matchend[6] in cclist and loopper3[0][cclist.index(matchend[6])] == True: getData3 += "&check6=yes" if matchend[7] in cclist and loopper3[0][cclist.index(matchend[7])] == True: getData3 += "&check7=yes" if matchend[8] in cclist and loopper3[0][cclist.index(matchend[8])] == True: getData3 += "&check8=yes" if matchend[9] in cclist and loopper3[0][cclist.index(matchend[9])] == True: getData3 += "&check9=yes" if matchend[10] in cclist and loopper3[0][cclist.index(matchend[10])] == True: getData3 += "&check10=yes" if matchend[11] in cclist and loopper3[0][cclist.index(matchend[11])] == True: getData3 += "&check11=yes" if matchend[12] in cclist and loopper3[0][cclist.index(matchend[12])] == True: getData3 += "&cas1=yes" if matchend[13] in cclist and loopper3[0][cclist.index(matchend[13])] == True: getData3 += "&cas2=yes" if matchend[14] in cclist and loopper3[0][cclist.index(matchend[14])] == True: getData3 += "&cas3=yes" print(matchend[15]) print(cclist.index(matchend[15])) if matchend[15] in cclist and loopper3[0][cclist.index(matchend[15])] == True: getData3 += "&cas4=yes" print(getData3) return getData3 def OutbetGetData(urlkey,adminkey,passkey, startDatekey, endDatekey): print("OutbetGetData") try: sloginUrl = "https://"+urlkey+"/pub/SuperGateway.php?c=900%2C"+adminkey+"%2C"+passkey response = requests.request("POST", sloginUrl, timeout=10,verify=False) #jsondata=json.loads(response.text) #SIDKey=rrr[2] print(response.status_code) if response.status_code==200:#如果網站有正常回應 if len(response.text)>3:#回應的是正確值 #==================外埔================================== payloado='data1='+startDatekey+'&data2='+endDatekey+'&checka=yes&check0=yes&check1=yes&check2=yes&check3=yes&check4=yes&check5=yes&check6=yes&check7=yes&check8=yes&check9=yes&check10=yes&check11=yes&cas1=yes&cas2=yes&cas3=yes&cas4=yes' GetUrlo="https://"+urlkey+"/func/supply/page/report/outbet_all.php" GetHeaderso = { 'Content-Type': 'application/x-www-form-urlencoded' } GetResponseo = requests.request("POST", GetUrlo, headers=GetHeaderso, data=payloado, timeout=10,verify=False) if len(GetResponseo.text)>5: print("有外埔") try: val=pd.DataFrame(pd.read_html(GetResponseo.text)[0])[:-2] val = val.drop(val.columns[0:3],axis=1) print(len(val)) WEBURLTXT=[] ADMINTXT=[] StartDATETXT=[] EndDATETXT=[] for i in range(len(val)): WEBURLTXT.append(urlkey) ADMINTXT.append(adminkey) StartDATETXT.append(startDatekey) EndDATETXT.append(endDatekey) val.insert(0,"開始日期",StartDATETXT) val.insert(1,"結束日期",EndDATETXT) val.insert(2,"網址",WEBURLTXT) val.insert(3,"帳戶",ADMINTXT) print(val) val.columns =["開始日期","結束日期","網址","帳戶","總量","退水","中獎","小計"] print(val) fordebugger="OK" except Exception as e: print(e) else: val=pd.DataFrame() fordebugger="OK" print("無外埔") return val,fordebugger,urlkey,adminkey else: val=pd.DataFrame() print("error 1") fordebugger="無法取得資料" return val,fordebugger,urlkey,adminkey if response.status_code!=200: val=pd.DataFrame() print("error 2") fordebugger="無法取得資料" return val,fordebugger,urlkey,adminkey except: val=pd.DataFrame() print("error 3") fordebugger="無法取得資料" return val,fordebugger,urlkey,adminkey class External(QThread): """ Runs a counter thread. """ countChanged = pyqtSignal(int)#介面用進度條 urlChanged=pyqtSignal(str)#介面用網址資訊 def run(self): try: ALLDataFrameList=[] DebugCodeList=[] ALLDataFrameList.append(refindlong) ALLDataFrameList.append(refindshort) ALLDataFrameList=pd.concat(ALLDataFrameList) #----------------------------------------------------------------------------------------------- #多執行續 with ThreadPoolExecutor(max_workers=10) as executor: futures = [] test=[] z=0 x=len(UrlList) for urlkey,adminkey,passkey,backupUrl in zip(UrlList,AdminList,PasswordList,backupUrlList): future=executor.submit(LongGetData,urlkey,adminkey,passkey, startDatekey, endDatekey,backupUrl,childAdminLs) futures.append(future)#已完成的 for future in as_completed(futures): test.append(list(future.result())) MDF,MDC,MURL,ADMINNNNNN=list(future.result()) #MDF=pd.concat([ALLDataFrameList,MDF]) #MDF.to_sql('流水帳', con=engine3, if_exists='append') MDCURL=MURL+"=>"+MDC percentvalues=((z+1)/x)*100 self.countChanged.emit(percentvalues) self.urlChanged.emit(MDCURL) z=z+1 #----------------------------------------------------------------------------------------------- ALLDataFrameList0,DebugCodeList,UrlDebugList,ADMINKEYLIST=zip(*test) ALLDataFrameList0=pd.concat(ALLDataFrameList0) neewDataFrmoe=pd.concat([ALLDataFrameList,ALLDataFrameList0]) print(neewDataFrmoe) #------------------------------------------------------------------------- #=============================LOGER====================================== LOGGER=[] y=0 for UrlDebugListlog,DebugCodeListlog,ADMINKEYLISTlog in zip(UrlDebugList,DebugCodeList,ADMINKEYLIST): if DebugCodeListlog=="OK": print("OK") else: LOGGER.append([]) randomNum=random.randint(0,9) nowTime=datetime.datetime.now().strftime("%Y-%m-%d-%H:%M:%S") nowTime=str(nowTime)+"---"+str(randomNum) LOGGER[y].append(coustomtxt) LOGGER[y].append(startDatekey+"-"+endDatekey) LOGGER[y].append(UrlDebugListlog) LOGGER[y].append(DebugCodeListlog) LOGGER[y].append(nowTime) LOGGER[y].append(ADMINKEYLISTlog) y=y+1 LOGGER=pd.DataFrame(LOGGER) if len(LOGGER)>0: LOGGER.columns =["客戶","查詢區間","網址","狀態","查詢時間","帳號"] else: print("NO LOG") print(LOGGER) #=================================================================================== end = time.time() self.urlChanged.emit("已執行"+str(end - start)+"秒 處理中...") #------------------------------------------------------------------------ #neewDataFrmoe.to_csv("M126UI.csv",encoding="utf_8_sig")#for debug print("FILE明子...asdasdasd:"+thisfile) #if thisfile=="A1.txt": # neewDataFrmoe.to_sql('流水帳', con=engine3, if_exists='append') #elif thisfile=="A2.txt" : # neewDataFrmoe.to_sql('後台流水帳', con=engine3, if_exists='append') LOGGER.to_sql('LOG', con=engine3, if_exists='append') closedatalodibg=LoadingYesorNo() end = time.time() print("執行時間:%f 秒" % (end - start)) self.urlChanged.emit("已執行"+str(end - start)+"秒 處理完成") print("DONE.....................100%") #window.close() app.quit() except Exception: logging.debug('debug message',exc_info=True) logging.info('info message',exc_info=True) logging.warning('warning message',exc_info=True) logging.error('error message',exc_info=True) logging.critical('critical message',exc_info=True) app1 = QtWidgets.QApplication([]) error_dialog = QtWidgets.QErrorMessage() error_dialog.setWindowTitle('ERROR') error_dialog.showMessage('連線資料錯誤') app1.exec_() finally: closedatalodibg=LoadingYesorNo() class External2(QThread): """ Runs a counter thread. """ countChanged = pyqtSignal(int)#介面用進度條 urlChanged=pyqtSignal(str)#介面用網址資訊 def run(self): try: ALLDataFrameList=[] DebugCodeList=[] ALLDataFrameList.append(refindoutbet) ALLDataFrameList=pd.concat(ALLDataFrameList) #----------------------------------------------------------------------------------------------- #多執行續 with ThreadPoolExecutor(max_workers=10) as executor: futures = [] test=[] z=0 x=len(UrlList) for urlkey,adminkey,passkey,backupUrl in zip(UrlList,AdminList,PasswordList,backupUrlList): future=executor.submit(OutbetGetData,urlkey,adminkey,passkey, startDatekey, endDatekey) futures.append(future)#已完成的 for future in as_completed(futures): test.append(list(future.result())) MDF,MDC,MURL,ADMINNNNNN=list(future.result()) #MDF=pd.concat([ALLDataFrameList,MDF]) #MDF.to_sql('流水帳', con=engine3, if_exists='append') MDCURL=MURL+"=>"+MDC percentvalues=((z+1)/x)*100 self.countChanged.emit(percentvalues) self.urlChanged.emit(MDCURL) z=z+1 #----------------------------------------------------------------------------------------------- ALLDataFrameList0,DebugCodeList,UrlDebugList,ADMINKEYLIST=zip(*test) ALLDataFrameList0=pd.concat(ALLDataFrameList0) neewDataFrmoe=pd.concat([ALLDataFrameList,ALLDataFrameList0]) print(neewDataFrmoe) #------------------------------------------------------------------------- #=============================LOGER====================================== LOGGER=[] y=0 for UrlDebugListlog,DebugCodeListlog,ADMINKEYLISTlog in zip(UrlDebugList,DebugCodeList,ADMINKEYLIST): if DebugCodeListlog=="OK": print("OK") else: LOGGER.append([]) randomNum=random.randint(0,9) nowTime=datetime.datetime.now().strftime("%Y-%m-%d-%H:%M:%S") nowTime=str(nowTime)+"---"+str(randomNum) LOGGER[y].append(coustomtxt) LOGGER[y].append(startDatekey+"-"+endDatekey) LOGGER[y].append(UrlDebugListlog) LOGGER[y].append(DebugCodeListlog) LOGGER[y].append(nowTime) LOGGER[y].append(ADMINKEYLISTlog) y=y+1 LOGGER=pd.DataFrame(LOGGER) if len(LOGGER)>0: LOGGER.columns =["客戶","查詢區間","網址","狀態","查詢時間","帳號"] else: print("NO LOG") print(LOGGER) #=================================================================================== end = time.time() self.urlChanged.emit("已執行"+str(end - start)+"秒 處理中...") #------------------------------------------------------------------------ #neewDataFrmoe.to_csv("M126UI.csv",encoding="utf_8_sig")#for debug print("FILE明子...asdasdasd:"+thisfile) #neewDataFrmoe.to_sql('後台外埔報表', con=engine3, if_exists='append') LOGGER.to_sql('LOG', con=engine3, if_exists='append') closedatalodibg=LoadingYesorNo() end = time.time() print("執行時間:%f 秒" % (end - start)) self.urlChanged.emit("已執行"+str(end - start)+"秒 處理完成") print("DONE.....................100%") #window.close() app.quit() except Exception: logging.debug('debug message',exc_info=True) logging.info('info message',exc_info=True) logging.warning('warning message',exc_info=True) logging.error('error message',exc_info=True) logging.critical('critical message',exc_info=True) app1 = QtWidgets.QApplication([]) error_dialog = QtWidgets.QErrorMessage() error_dialog.setWindowTitle('ERROR') error_dialog.showMessage('連線資料錯誤') app1.exec_() finally: closedatalodibg=LoadingYesorNo() class Actions(QDialog): """ Simple dialog that consists of a Progress Bar and a Button. Clicking on the button results in the start of a timer and updates the progress bar.. """ def __init__(self): super().__init__() self.initUI() def initUI(self): self.setWindowTitle('D0128') self.setWindowFlags(Qt.WindowStaysOnTopHint) self.progress = QProgressBar(self) self.progress.setGeometry(20, 20, 300, 25) self.progress.setMaximum(100) self.label=QLabel(self) self.label.setGeometry(20, 50, 211, 31) self.label.setText("- 自動導入中請勿關閉視窗 - ") self.label2=QLabel(self) self.label2.setGeometry(20, 70, 211, 31) self.show() self.calc = External() self.calc.countChanged.connect(self.onCountChanged) self.calc.urlChanged.connect(self.onUrlChanged) self.calc.start() def onCountChanged(self, value): self.progress.setValue(value) def onUrlChanged(self, urlstr): self.label2.setText(urlstr) class Actions2(QDialog): """ Simple dialog that consists of a Progress Bar and a Button. Clicking on the button results in the start of a timer and updates the progress bar. """ def __init__(self): super().__init__() self.initUI() def initUI(self): self.setWindowTitle('連線中...') self.label=QLabel(self) #self.label.setFont(QtGui.QFont('Arial', 12)) self.label.setGeometry(20, 20,120,30) #self.label.setTextFormat(QtCore.Qt.AutoText) self.label.setText("- 取得連線 請按開始 -") self.button = QPushButton('開始', self) self.button.move(50, 80) self.show() self.button.clicked.connect(self.onButtonClick) def onButtonClick(self): self.close() class Actions3(QDialog): """ Simple dialog that consists of a Progress Bar and a Button. Clicking on the button results in the start of a timer and updates the progress bar.. """ def __init__(self): super().__init__() self.initUI() def initUI(self): self.setWindowTitle('D0150') self.setWindowFlags(Qt.WindowStaysOnTopHint) self.progress = QProgressBar(self) self.progress.setGeometry(20, 20, 300, 25) self.progress.setMaximum(100) self.label=QLabel(self) self.label.setGeometry(20, 50, 211, 31) self.label.setText("- 自動導入中請勿關閉視窗 - ") self.label2=QLabel(self) self.label2.setGeometry(20, 70, 211, 31) self.show() self.calc = External2() self.calc.countChanged.connect(self.onCountChanged) self.calc.urlChanged.connect(self.onUrlChanged) self.calc.start() def onCountChanged(self, value): self.progress.setValue(value) def onUrlChanged(self, urlstr): self.label2.setText(urlstr) try: #app1 = QApplication(sys.argv) #window2 = Actions2() FIle="A1.txt" FIle2="B.txt" FIle3="A2.txt" def LoadingYesorNo(): SUPDA=db_session2.query(Someoneupdate).filter_by(正在自動導入中='YES').first() SUPDAc=db_session2.query(Someoneupdate).filter_by(正在自動導入中='YES').count() print(SUPDAc) if (SUPDAc==1): SUPDA.正在自動導入中='NO' db_session2.commit() coustomtxt,bdtxt=loadCSV() engine = create_engine('mssql+pyodbc://'+bdtxt+'?driver=SQL+Server+Native+Client+11.0') print (coustomtxt) engine3=connectEngine(coustomtxt,engine) ''' @event.listens_for(engine3, 'before_cursor_execute') def receive_before_cursor_execute(conn, cursor, statement, params, context, executemany): if executemany: cursor.fast_executemany = True cursor.commit() ''' DB_session2 = sessionmaker(engine3) db_session2= DB_session2() log_Engine=CreateLogEngine() while True: if os.path.isfile(FIle)==True: thisfile="A1.txt" os.remove(FIle) startDatekey,endDatekey,allpart=DateDataLoad(engine3,db_session2) contforloop,loopper2,childAdminLs,loopper3=LoadCustomData(engine3,allpart) UrlList,AdminList,PasswordList,backupUrlList=zip(*loopper2) #webselect="GameType%5B%5D=35&GameType%5B%5D=22&GameType%5B%5D=11&GameType%5B%5D=12&GameType%5B%5D=13&GroupType%5B%5D=118&GroupType%5B%5D=109&GroupType%5B%5D=108&GroupType%5B%5D=102&GroupType%5B%5D=160&GroupType%5B%5D=159&GroupType%5B%5D=158&GroupType%5B%5D=157&GroupType%5B%5D=156&GroupType%5B%5D=155&GroupType%5B%5D=154&GroupType%5B%5D=153&GroupType%5B%5D=107&GroupType%5B%5D=106&GroupType%5B%5D=105&GroupType%5B%5D=104&GroupType%5B%5D=103&GroupType%5B%5D=101" print(UrlList,AdminList,PasswordList)#,webselect) start = time.time() # refindlong=pd.DataFrame(columns =["開始日期","結束日期","網址","帳戶","名稱","總量","退水","中獎","輸贏","佔成輸贏","水倍差","上繳金額","自已總輸贏","上繳貢獻額","貢獻額","貢獻度","下注明細","玩法明細","調盤退水","調退實佔","上繳","會員","代理","總代理","股東","大股東","總監"]) # refindshort=pd.DataFrame(columns =["開始日期","結束日期","網址","帳戶","客戶s","總量s","中獎s","輸贏s","客戶小計s","代理小計s","總代理小計s","股東小計s","大股東小計s","總監小計s","個人所得s","水差s","下注明細s","查看對帳s","隨機碼"]) refindlong=pd.DataFrame(columns =["開始日期","結束日期","網址","帳戶","名稱","總量","退水","中獎","輸贏","佔成輸贏","水倍差","上繳金額","自已總輸贏","上繳貢獻額","貢獻額","貢獻度","下注明細","玩法明細","調盤退水","調退實佔","上繳","會員","代理","總代理","股東","大股東","總監"]) refindshort=pd.DataFrame(columns =["開始日期","結束日期","網址","帳戶","客戶s","總量s","中獎s","輸贏s","客戶小計s","代理小計s","總代理小計s","股東小計s","大股東小計s","總監小計s","個人所得s","水差s","下注明細s","查看對帳s","貢獻額s","貢獻度s","調盤退水s","調退實佔s","大總監","系統商","隨機碼"]) #refindoutbet=pd.DataFrame(columns =["開始日期","結束日期","網址","帳戶","總量","退水","中獎","小計"]) #window2.close() #app1.quit() #app1.exec_() app = QtWidgets.QApplication(sys.argv) window = Actions() app.exec_() del app del window #sys.exit(app.exec_()) continue if os.path.isfile(FIle3)==True: thisfile="A2.txt" os.remove(FIle3) startDatekey,endDatekey,allpart=DateDataLoad(engine3,db_session2) contforloop,loopper2,childAdminLs,loopper3=LoadCustomData(engine3,allpart) UrlList,AdminList,PasswordList,backupUrlList=zip(*loopper2) print(UrlList,AdminList,PasswordList) start = time.time() # refindlong=pd.DataFrame(columns =["開始日期","結束日期","網址","帳戶","名稱","總量","退水","中獎","輸贏","佔成輸贏","水倍差","上繳金額","自已總輸贏","上繳貢獻額","貢獻額","貢獻度","下注明細","玩法明細","調盤退水","調退實佔","上繳","會員","代理","總代理","股東","大股東","總監"]) # refindshort=pd.DataFrame(columns =["開始日期","結束日期","網址","帳戶","客戶s","總量s","中獎s","輸贏s","客戶小計s","代理小計s","總代理小計s","股東小計s","大股東小計s","總監小計s","個人所得s","水差s","下注明細s","查看對帳s","隨機碼"]) refindlong=pd.DataFrame(columns =["開始日期","結束日期","網址","帳戶","名稱","總量","退水","中獎","輸贏","佔成輸贏","水倍差","上繳金額","自已總輸贏","上繳貢獻額","貢獻額","貢獻度","下注明細","玩法明細","調盤退水","調退實佔","上繳","會員","代理","總代理","股東","大股東","總監"]) refindshort=pd.DataFrame(columns =["開始日期","結束日期","網址","帳戶","客戶s","總量s","中獎s","輸贏s","客戶小計s","代理小計s","總代理小計s","股東小計s","大股東小計s","總監小計s","個人所得s","水差s","下注明細s","查看對帳s","貢獻額s","貢獻度s","調盤退水s","調退實佔s","大總監","系統商","隨機碼"]) refindoutbet=pd.DataFrame(columns =["開始日期","結束日期","網址","帳戶","總量","退水","中獎","小計"]) #window2.close() #app1.quit() #app1.exec_() app = QtWidgets.QApplication(sys.argv) window = Actions() app.exec_() del app del window #sys.exit(app.exec_()) app = QtWidgets.QApplication(sys.argv) window = Actions3() app.exec_() del app del window continue if os.path.isfile(FIle2)==True: os.remove(FIle2) break time.sleep(1) #sys.exit() except: traceback.print_exc() # 捕捉異常,並將異常傳播資訊輸出控制檯 traceback.print_exc(file=open('log.txt', 'a')) logging.debug('debug message',exc_info=True) logging.info('info message',exc_info=True) logging.warning('warning message',exc_info=True) logging.error('error message',exc_info=True) logging.critical('critical message',exc_info=True) app2 = QtWidgets.QApplication([]) error_dialog = QtWidgets.QErrorMessage() error_dialog.setWindowTitle('ERROR') error_dialog.showMessage('網路DRIVER錯誤') app2.exec_() finally: closedatalodibg=LoadingYesorNo()