def start():
homePage()
sleep(3)
fundPage()
fundData()
fundData()
fundExcel(n0)
def homePage():
fundlist=['LU0095030564']
for i in fundlist:
page = rpa.app.chrome.create('https://www.morningstar.hk/hk/screener/fund.aspx#?filtersSelectedValue=%7B%22term%22:%22'+i+'%22%7D')
sleep(3)
aud=page.value('参与者身份确认',index = 1)
if aud!='':
page.click('选择', index = 1, simulate = True, button = 'left')
page.click('接受', index = 1, simulate = True, button = 'left')
l=page.value('中文',index = 1)
if l=='中文':
page.click('中文', index = 1, simulate = True, button = 'left')
def fundPage():
page = rpa.app.chrome.catch('Mutual Funds Tools and News - Hong Kong | Morningstar Asia', mode='title', pattern='equal')
page.click('基金链接', index = 1, simulate = True, button = 'left')
def fundData():
page = rpa.app.chrome.catch('Morningstar', mode='title', pattern='contain')
page.click('表现', index = 1, simulate = True, button = 'left')
page.value('基金名称',index = 1)
page.value('星星',index = 1)
m=page.count("基本信息")
for n in range(1,m+1):
n0=page.value('基本信息',index = n)
print(n0)
b=page.count('总回报标题')
for bs in range(1,b+1):
n1=page.value("总回报标题",index=bs)
z=page.count("总回报")
for y in range(1,z+1):
n2=page.value('总回报',index = y)
hs=page.count("追踪回报标题")
for hsx in range(1,hs+1):
n3=page.value("追踪回报标题",index=hsx)
h=page.count('追踪回报')
for s in range(1,h+1):
n4=page.value('追踪回报',index=s)
return n0,n1,n2,n3,n4
def fundExcel(n0):
path=r'./基金.xlsx'
data=pd.DataFrame()
data.to_excel(path)
dt=pd.Series(n0)
print(dt)