上源码
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")
说明
- prettytable 通过表格格式化打印基金数据便于浏览数据
- 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"});
到此这篇关于利用python实时刷新基金估值(摸鱼小工具)的文章就介绍到这了,更多相关python基金估值内容请搜索华域联盟以前的文章或继续浏览下面的相关文章希望大家以后多多支持华域联盟!
您可能感兴趣的文章:
- python 简单的股票基金爬虫
- Python批量获取基金数据的方法步骤
- Python获取基金网站网页内容、使用BeautifulSoup库分析html操作示例
- Python多进程方式抓取基金网站内容的方法分析
- Python学习笔记之抓取某只基金历史净值数据实战案例
声明:本站(华域联盟www.cnhackhy.com)所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。


评论(0)