1 Star 0 Fork 3

joozen/pythondict-quant

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
fetch_stock.py 738 Bytes
一键复制 编辑 原始数据 按行查看 历史
# Python实用宝典
# 2021-06-13
# 文件名: fetch_stock.py
import time
import requests
from prometheus_client import start_http_server, CollectorRegistry, Gauge
reg = CollectorRegistry()
gauge = Gauge(
'rank', '人气榜排名',
['stock_id'], registry=reg
)
def process_request():
url = "https://emappdata.eastmoney.com/stockrank/getAllCurrentList"
kwargs = {
"appId": "appId01",
"pageNo": 1,
"pageSize": "100",
}
result = requests.post(url, json=kwargs).json()
for i in result.get("data", []):
gauge.labels(stock_id=i["sc"]).set(i["rk"])
time.sleep(60)
if __name__ == '__main__':
start_http_server(8000, registry=reg)
while True:
process_request()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/joozen/pythondict-quant.git
git@gitee.com:joozen/pythondict-quant.git
joozen
pythondict-quant
pythondict-quant
master

搜索帮助