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)
在start()函数中你要先给n0赋值,代码中这个n0是从fundData()函数返回的,那么你就要在start()函数中,用n0=fundData()[0],然后将n0作为参数传递给fundExcel函数。
调用fundExcel函数的时候,少了一个参数。
您好,我是有问必答小助手,你的问题已经有小伙伴为您解答了问题,您看下是否解决了您的问题,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632
非常感谢您使用有问必答服务,为了后续更快速的帮您解决问题,现诚邀您参与有问必答体验反馈。您的建议将会运用到我们的产品优化中,希望能得到您的支持与协助!
速戳参与调研>>>https://t.csdnimg.cn/Kf0y