代码拉取完成,页面将自动刷新
# 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()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。