feat: 添加基金相关文件
This commit is contained in:
parent
fca812778c
commit
d28f27603c
|
|
@ -1,13 +1,15 @@
|
||||||
|
|
||||||
# import traceback
|
# import traceback
|
||||||
|
from abc import ABC, abstractmethod
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from smtplib import SMTP_SSL
|
|
||||||
|
|
||||||
from helium import *
|
from helium import *
|
||||||
from selenium.webdriver import ChromeOptions
|
from selenium.webdriver import ChromeOptions
|
||||||
|
|
||||||
|
|
||||||
class Fund(object):
|
class Fund(ABC):
|
||||||
def __init__(self, mobile=True, headless=True):
|
def __init__(self, url, mobile=True, headless=True):
|
||||||
|
self.url = url
|
||||||
self.mobile_emulation = {'deviceName': 'iPad Mini'}
|
self.mobile_emulation = {'deviceName': 'iPad Mini'}
|
||||||
self.mobile = mobile
|
self.mobile = mobile
|
||||||
self.headless = headless
|
self.headless = headless
|
||||||
|
|
@ -21,7 +23,7 @@ class Fund(object):
|
||||||
if self.mobile:
|
if self.mobile:
|
||||||
chrome_options.add_experimental_option("mobileEmulation", self.mobile_emulation)
|
chrome_options.add_experimental_option("mobileEmulation", self.mobile_emulation)
|
||||||
chrome_options.add_argument('user-agent="Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1"')
|
chrome_options.add_argument('user-agent="Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1"')
|
||||||
start_chrome("https://login.1234567.com.cn/login", options=chrome_options)
|
start_chrome(self.url, options=chrome_options)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
@ -30,21 +32,10 @@ class Fund(object):
|
||||||
print("value: ", value)
|
print("value: ", value)
|
||||||
kill_browser()
|
kill_browser()
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
def login(self):
|
def login(self):
|
||||||
write('15359827092', into=S('input#tbname'))
|
pass
|
||||||
write('c113w927j', into=S('input#tbpwd'))
|
|
||||||
click(S('input#protocolCheckbox'))
|
|
||||||
click(S('a#btn_login'))
|
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
def my_assets(self):
|
def my_assets(self):
|
||||||
click(S('a.aui_close'))
|
pass
|
||||||
elem_all_value = S('span#all_value')
|
|
||||||
wait_until(elem_all_value.exists)
|
|
||||||
print("资产总额:")
|
|
||||||
print(elem_all_value.web_element.text)
|
|
||||||
|
|
||||||
|
|
||||||
with Fund(headless=False, mobile=False) as fund:
|
|
||||||
fund.login()
|
|
||||||
fund.my_assets()
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
# import traceback
|
||||||
|
from email.mime.text import MIMEText
|
||||||
|
from smtplib import SMTP_SSL
|
||||||
|
|
||||||
|
from helium import *
|
||||||
|
|
||||||
|
from funds import Fund
|
||||||
|
|
||||||
|
|
||||||
|
class EFund(Fund):
|
||||||
|
"""
|
||||||
|
易方达基金
|
||||||
|
"""
|
||||||
|
def __init__(self, url="https://e.efunds.com.cn/", mobile=True, headless=True):
|
||||||
|
super().__init__(url, mobile=mobile, headless=headless)
|
||||||
|
|
||||||
|
|
||||||
|
def login(self):
|
||||||
|
write('15359827092', into=S('input#certID'))
|
||||||
|
write('DJUWwiN4ep9XzsN', into=S('input#tradepassword'))
|
||||||
|
click(S('div#agreementRadioBox'))
|
||||||
|
click(S('input#submitBtn'))
|
||||||
|
|
||||||
|
def my_assets(self):
|
||||||
|
asset_el = S('td.f-tl.fis-col')
|
||||||
|
if not asset_el.exists:
|
||||||
|
wait_until(asset_el.exists)
|
||||||
|
print(f"{asset_el.web_element.text}")
|
||||||
|
print("资产总额:")
|
||||||
|
|
||||||
|
|
||||||
|
with EFund(headless=False, mobile=False) as fund:
|
||||||
|
fund.login()
|
||||||
|
fund.my_assets()
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
# import traceback
|
||||||
|
from email.mime.text import MIMEText
|
||||||
|
from smtplib import SMTP_SSL
|
||||||
|
|
||||||
|
from helium import *
|
||||||
|
|
||||||
|
from funds import Fund
|
||||||
|
|
||||||
|
|
||||||
|
class GfFund(Fund):
|
||||||
|
"""
|
||||||
|
广发基金
|
||||||
|
"""
|
||||||
|
def __init__(self, url="https://trade.gffunds.com.cn/login", mobile=True, headless=True):
|
||||||
|
super().__init__(url, mobile=mobile, headless=headless)
|
||||||
|
|
||||||
|
def login(self):
|
||||||
|
write('15359827092', into=S('input#userName'))
|
||||||
|
write('Q6bcV7tvEw4jiZT', into=S('input#password'))
|
||||||
|
click(S('span.ant-checkbox'))
|
||||||
|
click(Text('登 录'))
|
||||||
|
|
||||||
|
def my_assets(self):
|
||||||
|
asset_el = S('span.text-x3l')
|
||||||
|
if not asset_el.exists:
|
||||||
|
wait_until(asset_el.exists)
|
||||||
|
print("资产总额:")
|
||||||
|
print(f"{asset_el.web_element.text}")
|
||||||
|
|
||||||
|
|
||||||
|
with GfFund(headless=False, mobile=False) as fund:
|
||||||
|
fund.login()
|
||||||
|
fund.my_assets()
|
||||||
Loading…
Reference in New Issue