摸鱼小工具_利用python实时刷新基金估值 效果预览
上源码
import requests import json import os from prettytable import PrettyTable import time fundlist = ['163817','161017','003860'] def GetFundJsonInfo(fundcode): url = "http://fundgz.1234567.com.cn/js/"+fundcode+".js" response = requests.get(url) fundDataInfo = response.text.split('({')[1] fundDataInfo = '{'+ fundDataInfo.split('})')[0] + '}' fundDataInfo = json.loads(fundDataInfo) return fundDataInfo os.system("cls") while True: table = PrettyTable(["名称","昨日净值","实时估值","增长率"]) for fund in fundlist: myfund = GetFundJsonInfo(fund) table.add_row([myfund['name'],myfund['dwjz'],myfund['gsz'],myfund['gszzl']]) print(table) time.sleep(5) os.system("cls")
说明
jsonpgz({"fundcode":"163817","name":"中银转债增强债券B","jzrq":"2021-09-10","dwjz":"3.1120","gsz":"3.1127","gszzl":"0.02","gztime":"2021-09-13 14:54"});