如何查找Paribu恐惧与贪婪指数图表背后的API端点?
获取Paribu自有恐惧与贪婪指数的实现方案
核心背景
Paribu趋势页面的恐惧与贪婪指数基于自有数据计算,与alternative.me公开API结果存在差异,且无独立API端点可直接调用。该数据已内嵌在页面的<script id="__NEXT_DATA__" type="application/json">标签中,可通过解析页面HTML获取。
数据定位
数据在JSON结构中的路径为:props.pageProps.fearAndGreed.history,数组内每个条目包含完整的指数信息,示例结构如下:
{ "value": 47, "timestamp": 1714176000000, "classification": "korku" }
value:恐惧与贪婪指数数值(范围0-100)timestamp:数据对应的毫秒级时间戳classification:指数分类(土耳其语,如korku代表恐惧,mutluluk代表贪婪)
提取实现示例
Python 版本
import requests from bs4 import BeautifulSoup import json # 请求目标页面 target_url = "https://www.paribu.com/kripto-trend-analizi" response = requests.get(target_url) soup = BeautifulSoup(response.text, "html.parser") # 提取并解析内嵌JSON数据 next_data_tag = soup.find("script", id="__NEXT_DATA__") paribu_data = json.loads(next_data_tag.string) # 获取恐惧与贪婪指数历史数据集 fear_greed_history = paribu_data["props"]["pageProps"]["fearAndGreed"]["history"] # 输出最新一条指数数据 latest_entry = fear_greed_history[-1] print(f"最新指数值: {latest_entry['value']}") print(f"对应时间戳: {latest_entry['timestamp']}") print(f"指数分类: {latest_entry['classification']}")
JavaScript 版本(浏览器控制台/Node.js)
// 在浏览器控制台直接执行 const nextDataScript = document.getElementById('__NEXT_DATA__'); const paribuData = JSON.parse(nextDataScript.textContent); // 提取指数数据 const fearGreedHistory = paribuData.props.pageProps.fearAndGreed.history; // 输出最新条目 const latestEntry = fearGreedHistory[fearGreedHistory.length - 1]; console.log(`最新指数值: ${latestEntry.value}`); console.log(`对应时间戳: ${latestEntry.timestamp}`); console.log(`指数分类: ${latestEntry.classification}`);
内容的提问来源于stack exchange,提问作者MiaTone
相关产品推荐
相关产品推荐

