py_scripts/fund.py

50 lines
1.6 KiB
Python

# import traceback
from email.mime.text import MIMEText
from smtplib import SMTP_SSL
from helium import *
from selenium.webdriver import ChromeOptions
class Fund(object):
def __init__(self, mobile=True, headless=True):
self.mobile_emulation = {'deviceName': 'iPad Mini'}
self.mobile = mobile
self.headless = headless
def __enter__(self):
chrome_options = ChromeOptions()
chrome_options.add_argument('--no-sandbox')
if self.headless:
chrome_options.add_argument('--headless')
if self.mobile:
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"')
start_chrome("https://login.1234567.com.cn/login", options=chrome_options)
return self
def __exit__(self, type, value, trace):
print("type: ", type )
print("value: ", value)
kill_browser()
def login(self):
write('15359827092', into=S('input#tbname'))
write('c113w927j', into=S('input#tbpwd'))
click(S('input#protocolCheckbox'))
click(S('a#btn_login'))
def my_assets(self):
click(S('a.aui_close'))
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()