diff --git a/autobasic/cj_clienttrader.py b/autobasic/cj_clienttrader.py index 1553cac..9178bf6 100644 --- a/autobasic/cj_clienttrader.py +++ b/autobasic/cj_clienttrader.py @@ -23,7 +23,9 @@ scripts_path = os.path.dirname(os.path.realpath(__file__)) from pathlib import Path root_path = Path(__file__).parent.parent -path = os.path.join(root_path,'broker_xiadan','金长江网上交易汇智版','xiadan.exe') + +# 直接默认使用C:'金长江网上交易汇智版','xiadan.exe' +path = os.path.join('C:','金长江网上交易汇智版','xiadan.exe') global engine engine = create_engine( @@ -128,6 +130,24 @@ class ChangJiangClientTrader: proxy_port = item['port'] set_proxy(proxy_ip, proxy_port) + + # ip和mac入库 + new_mac = set_mac.get_macinfos() + insert_data_df = pd.DataFrame([{'As_Of_Date': datetime.date.today(), + 'Broker': '长江证券', + 'Account_Number': self.account_name, + 'Timestamp': datetime.datetime.now(), + 'Proxy': True, + 'IP_Type': '动态IP', + 'Mac': new_mac, + 'IP': proxy_ip, + 'Port': proxy_port, + 'Location': item['prov'] + ':' + item['city']}]) + insert_data_df.to_sql('trade_proxyip', engine, schema='user_center', index=False, if_exists='append') + self.log.info(f'IP:{proxy_ip} MAC:{new_mac} 已入库') + + + # 启动软件进程,输入账号密码 self._app = pywinauto.Application().start(self.path) while True: try: @@ -167,20 +187,7 @@ class ChangJiangClientTrader: break self._app.window(title_re='网上股票交易系统5.0.*').wait("ready",timeout=60) - # ip和mac入库 - new_mac = set_mac.get_macinfos() - insert_data_df = pd.DataFrame([{'As_Of_Date': datetime.date.today(), - 'Broker': '长江证券', - 'Account_Number': self.account_name, - 'Timestamp': datetime.datetime.now(), - 'Proxy': True, - 'IP_Type': '动态IP', - 'Mac': new_mac, - 'IP': proxy_ip, - 'Port': proxy_port, - 'Location': item['prov'] + ':' + item['city']}]) - insert_data_df.to_sql('trade_proxyip', engine, schema='user_center', index=False, if_exists='append') - self.log.info(f'IP:{proxy_ip} MAC:{new_mac} 已入库') + #关闭弹窗 for i in range(3): diff --git a/autobasic/dw_clienttrader.py b/autobasic/dw_clienttrader.py index 6029bc6..7b695bc 100644 --- a/autobasic/dw_clienttrader.py +++ b/autobasic/dw_clienttrader.py @@ -146,26 +146,8 @@ class DongWuClientTrader: proxy_ip = item['ip'] proxy_port = item['port'] set_proxy(proxy_ip,proxy_port) - self.logger.info('全局代理设置成功') - # 开始登录 - time.sleep(2) - self._app = pywinauto.Application().start(self.path) - while True: - try: - self._app.window(title_re='用户登录.*').wait("ready") - break - except RuntimeError: - pass - self._app.window(title_re='用户登录.*').Edit1.type_keys(self.securities_name) - time.sleep(0.1) - self._app.window(title_re='用户登录.*').Edit2.type_keys(self.securities_password) - time.sleep(0.1) - - pywinauto.keyboard.send_keys("{ENTER}") - self._app.window(title_re='网上股票交易系统5.0.*').wait("ready",timeout=30) - # ip和mac入库 new_mac = set_mac.get_macinfos() insert_data_df = pd.DataFrame([{'As_Of_Date': datetime.date.today(), @@ -180,6 +162,21 @@ class DongWuClientTrader: 'Location': item['prov'] + ':' + item['city']}]) insert_data_df.to_sql('trade_proxyip', engine, schema='user_center', index=False, if_exists='append') self.logger.info(f'IP:{proxy_ip} MAC:{new_mac} 已入库') + + + # 开始登录 + self._app = pywinauto.Application().start(self.path) + + self._app.window(title_re='用户登录.*').wait("ready",timeout=30) + self._app.window(title_re='用户登录.*').Edit1.type_keys(self.securities_name) + time.sleep(0.1) + self._app.window(title_re='用户登录.*').Edit2.type_keys(self.securities_password) + time.sleep(0.1) + + pywinauto.keyboard.send_keys("{ENTER}") + self._app.window(title_re='网上股票交易系统5.0.*').wait("ready",timeout=30) + + #关闭弹窗 for i in range(3): self._turn_off_advertising() diff --git a/autobasic/gf_clienttrader.py b/autobasic/gf_clienttrader.py index 0ccea9f..a422dd5 100644 --- a/autobasic/gf_clienttrader.py +++ b/autobasic/gf_clienttrader.py @@ -24,7 +24,7 @@ scripts_path = os.path.dirname(os.path.realpath(__file__)) from pathlib import Path root_path = Path(__file__).parent.parent from config import ssid,password -path = os.path.join(root_path,'broker_xiadan','gfzqrzrq','xiadan.exe') +path = os.path.join('C:','gfzqrzrq','xiadan.exe') global engine engine = create_engine( @@ -111,6 +111,22 @@ class GFClientTrader: set_proxy(proxy_ip, proxy_port) self.log.info('全局代理设置成功') + # ip和mac入库 + new_mac = set_mac.get_macinfos() + insert_data_df = pd.DataFrame([{'As_Of_Date': datetime.date.today(), + 'Broker': '广发证券', + 'Account_Number': self.account_name, + 'Timestamp': datetime.datetime.now(), + 'Proxy': True, + 'IP_Type': '动态IP', + 'Mac': new_mac, + 'IP': proxy_ip, + 'Port': proxy_port, + 'Location': item['prov'] + ':' + item['city']}]) + insert_data_df.to_sql('trade_proxyip', engine, schema='user_center', index=False, if_exists='append') + self.log.info(f'IP:{proxy_ip} MAC:{new_mac} 已入库') + + # 启动软件进程,输入账号密码 self._app = pywinauto.Application().start(self.path) while True: @@ -133,20 +149,7 @@ class GFClientTrader: self._close_prompt_windows() self._app.window(title_re='核新网上交易系统.*').wait("ready",timeout=60) - # ip和mac入库 - new_mac = set_mac.get_macinfos() - insert_data_df = pd.DataFrame([{'As_Of_Date': datetime.date.today(), - 'Broker': '广发证券', - 'Account_Number': self.account_name, - 'Timestamp': datetime.datetime.now(), - 'Proxy': True, - 'IP_Type': '动态IP', - 'Mac': new_mac, - 'IP': proxy_ip, - 'Port': proxy_port, - 'Location': item['prov'] + ':' + item['city']}]) - insert_data_df.to_sql('trade_proxyip', engine, schema='user_center', index=False, if_exists='append') - self.log.info(f'IP:{proxy_ip} MAC:{new_mac} 已入库') + #关闭弹窗 # for i in range(3): # self._turn_off_advertising() diff --git a/autobasic/hualong_clienttrader.py b/autobasic/hualong_clienttrader.py index f412c3a..8a48c11 100644 --- a/autobasic/hualong_clienttrader.py +++ b/autobasic/hualong_clienttrader.py @@ -153,6 +153,22 @@ class HLClientTrader: set_proxy(proxy_ip, proxy_port) self.logger.info('全局代理设置成功') + # ip和mac入库 + new_mac = set_mac.get_macinfos() + insert_data_df = pd.DataFrame([{'As_Of_Date': datetime.date.today(), + 'Broker': '华龙证券', + 'Account_Number': self.account_name, + 'Timestamp': datetime.datetime.now(), + 'Proxy': True, + 'IP_Type': '动态IP', + 'Mac': new_mac, + 'IP': proxy_ip, + 'Port': proxy_port, + 'Location': item['prov'] + ':' + item['city']}]) + insert_data_df.to_sql('trade_proxyip', engine, schema='user_center', index=False, if_exists='append') + self.logger.info(f'IP:{proxy_ip} MAC:{new_mac} 已入库') + + #启动软件进程,输入账号密码 self._app = pywinauto.Application().start(self.path) @@ -212,20 +228,7 @@ class HLClientTrader: # self._close_prompt_windows() self._app.window(title_re='通达信网上交易.*').wait("ready",timeout=30) - # ip和mac入库 - new_mac = set_mac.get_macinfos() - insert_data_df = pd.DataFrame([{'As_Of_Date': datetime.date.today(), - 'Broker': '华龙证券', - 'Account_Number': self.account_name, - 'Timestamp': datetime.datetime.now(), - 'Proxy': True, - 'IP_Type': '动态IP', - 'Mac': new_mac, - 'IP': proxy_ip, - 'Port': proxy_port, - 'Location': item['prov'] + ':' + item['city']}]) - insert_data_df.to_sql('trade_proxyip', engine, schema='user_center', index=False, if_exists='append') - self.logger.info(f'IP:{proxy_ip} MAC:{new_mac} 已入库') + #设置主窗口及菜单窗口 diff --git a/autobasic/huatai_clienttrader.py b/autobasic/huatai_clienttrader.py index 0a7fc27..669bd23 100644 --- a/autobasic/huatai_clienttrader.py +++ b/autobasic/huatai_clienttrader.py @@ -23,7 +23,7 @@ scripts_path = os.path.dirname(os.path.realpath(__file__)) from pathlib import Path root_path = Path(__file__).parent.parent from config import ssid,password -path = os.path.join(root_path,'broker_xiadan','华泰证券网上交易委托系统','xiadan.exe') +path = os.path.join('C:','华泰证券网上交易委托系统','xiadan.exe') global engine engine = create_engine( @@ -113,6 +113,22 @@ class HTClientTrader: set_proxy(proxy_ip, proxy_port) self.log.info('全局代理设置成功') + # ip和mac入库 + new_mac = set_mac.get_macinfos() + insert_data_df = pd.DataFrame([{'As_Of_Date': datetime.date.today(), + 'Broker': '华泰证券', + 'Account_Number': self.account_name, + 'Timestamp': datetime.datetime.now(), + 'Proxy': True, + 'IP_Type': '动态IP', + 'Mac': new_mac, + 'IP': proxy_ip, + 'Port': proxy_port, + 'Location': item['prov'] + ':' + item['city']}]) + insert_data_df.to_sql('trade_proxyip', engine, schema='user_center', index=False, if_exists='append') + self.log.info(f'IP:{proxy_ip} MAC:{new_mac} 已入库') + + self._app = pywinauto.Application().start(self.path) while True: try: @@ -137,20 +153,7 @@ class HTClientTrader: # for i in range(3): # self._turn_off_advertising() self._app.window(title_re='网上股票交易系统5.0.*').wait("ready",timeout=30) - # ip和mac入库 - new_mac = set_mac.get_macinfos() - insert_data_df = pd.DataFrame([{'As_Of_Date': datetime.date.today(), - 'Broker': '华泰证券', - 'Account_Number': self.account_name, - 'Timestamp': datetime.datetime.now(), - 'Proxy': True, - 'IP_Type': '动态IP', - 'Mac': new_mac, - 'IP': proxy_ip, - 'Port': proxy_port, - 'Location': item['prov'] + ':' + item['city']}]) - insert_data_df.to_sql('trade_proxyip', engine, schema='user_center', index=False, if_exists='append') - self.log.info(f'IP:{proxy_ip} MAC:{new_mac} 已入库') + # 关闭弹窗 self._close_prompt_windows() diff --git a/autobasic/zxjt_clienttrader.py b/autobasic/zxjt_clienttrader.py index 39e0898..d115493 100644 --- a/autobasic/zxjt_clienttrader.py +++ b/autobasic/zxjt_clienttrader.py @@ -23,7 +23,7 @@ scripts_path = os.path.dirname(os.path.realpath(__file__)) from pathlib import Path root_path = Path(__file__).parent.parent -path = os.path.join(root_path,'broker_xiadan','中信建投网上交易极速版(同花顺)','xiadan.exe') +path = os.path.join('C:','中信建投网上交易极速版(同花顺)','xiadan.exe') global engine engine = create_engine( 'mysql+pymysql://cn_ainvest_db:cn_ainvest_sd3a1@rm-2zewagytttzk6f24xno.mysql.rds.aliyuncs.com:3306' @@ -110,6 +110,22 @@ class ZXJTClientTrader: set_proxy(proxy_ip, proxy_port) self.log.info('全局代理设置成功') + # ip和mac入库 + new_mac = set_mac.get_macinfos() + insert_data_df = pd.DataFrame([{'As_Of_Date': datetime.date.today(), + 'Broker': '中信建投', + 'Account_Number': self.account_name, + 'Timestamp': datetime.datetime.now(), + 'Proxy': True, + 'IP_Type': '动态IP', + 'Mac': new_mac, + 'IP': proxy_ip, + 'Port': proxy_port, + 'Location': item['prov'] + ':' + item['city']}]) + insert_data_df.to_sql('trade_proxyip', engine, schema='user_center', index=False, if_exists='append') + self.log.info(f'IP:{proxy_ip} MAC:{new_mac} 已入库') + + # 启动软件进程,输入账号密码 self._app = pywinauto.Application().start(self.path) time.sleep(0.5) @@ -129,20 +145,7 @@ class ZXJTClientTrader: self._app.window(title_re='网上股票交易系统.*').wait("ready",timeout=30) - # ip和mac入库 - new_mac = set_mac.get_macinfos() - insert_data_df = pd.DataFrame([{'As_Of_Date': datetime.date.today(), - 'Broker': '中信建投', - 'Account_Number': self.account_name, - 'Timestamp': datetime.datetime.now(), - 'Proxy': True, - 'IP_Type': '动态IP', - 'Mac': new_mac, - 'IP': proxy_ip, - 'Port': proxy_port, - 'Location': item['prov'] + ':' + item['city']}]) - insert_data_df.to_sql('trade_proxyip', engine, schema='user_center', index=False, if_exists='append') - self.log.info(f'IP:{proxy_ip} MAC:{new_mac} 已入库') + #关闭弹窗 self._close_prompt_windows()