我的脚本在spyder中工作,但当我尝试在任务调度(使用bat文件)中运行它时,它不会执行任何操作。我相信这是URL请求出现问题的原因,我可能需要使用URL解析器。。。但我不确定这对我的代码会起什么作用。(API密钥不是我的,而是测试员)
import urllib.request as request
import json
import pandas as pd
ETFS = ["VTI"]
def Name (ticker):
url = "https://eodhistoricaldata.com/api/fundamentals/{ticker}.US?api_token=OeAFFmMliFG5orCUuwAKQ8l4WWFQ67YX".format(ticker=ticker)
with request.urlopen(url) as response:
source = response.read()
data = json.loads(source)
type(data.get('General',{}).get('Name', []))
len(data.get('General',{}).get('Name', []))
Name = (data.get('General',{}).get('Name', []))
return (Name)
resultname = list(map(Name, ETFS))
d = { "Ticker": ETFS, 'Name': resultname}
dfx = pd.DataFrame(data=d)
dfx.to_excel("Equity ETFs.xlsx")
目前没有回答
相关问题 更多 >
编程相关推荐