东方财富官方API接口,是需要付费的,小散户可以使用东方财富板块页面进行实时跟进板块数据
东方财富板块页面对应的API接口是push2.eastmoney.com
使用这个即可提取页面上信息 样例代码如下:
def get_hangye_data():
ret_data = []
try:
url = 'https://push2.eastmoney.com/api/qt/clist/get?cb=jQuery112307879834664846898_1630941013041&fid=f62&po=1&pz=60&pn=1&np=1&fltt=2&invt=2&ut=b2884a393a59ad64002292a3e90d46a5&fs=m%3A90+t%3A2&fields=f12%2Cf14%2Cf2%2Cf3%2Cf62%2Cf184%2Cf66%2Cf69%2Cf72%2Cf75%2Cf78%2Cf81%2Cf84%2Cf87%2Cf204%2Cf205%2Cf124%2Cf1%2Cf13'
ret = requests.get(url)
if ret.status_code == 200:
data =str(ret.content,encoding='utf-8')
data = data.replace('jQuery112307879834664846898_1630941013041(','').strip()
data = data[:-1].replace(")",'')
#print(data)
data = json.loads(data)
#print(data)
if 'data' in data:
data = data['data']
if 'diff' in data:
for item in data['diff']:
if 'f62' in item and float(item['f62']) > 0 and 'f66' in item and float(item['f66']) > 0 : # 主力流入 超大单流入
if 'f3' in item and float(item['f3']) > 0: # 上涨
ret_data.append(item)
except Exception as e:
print_except(sys._getframe().f_code.co_name, sys.exc_info(), e)
return ret_data
返回数据的研究对照表,其他字段有需要 可以继续研究一下
{
"f1": 2,
"f2": 17051.29,
"f3": 2.05,#今日涨跌幅
"f12": "BK0447",
"f13": 90,
"f14": "电子信息",#行业名称
"f62": 2565575424.0,#今日主力净流入
"f66": 2834106880.0,#今日超大单净流入
"f69": 7.16,
"f72": -268531456.0,
"f75": -0.68,
"f78": -1462089216.0,
"f81": -3.69,
"f84": -1103485952.0,
"f87": -2.79,
"f124": 1631086803,
"f184": 6.48, #今日主力净流入占比
"f204": "东方财富", #今日主力净流入最大股
"f205": "300059", #今日主力净流入最大股股票
"f206": 0
}
点击行业数据,将会看到行业下对应的股票列表,对应接口
提取数据样例
def get_gegu_data(item):
global total_zhangting
total_zhangting = 0
ret_data = []
try:
url = 'https://push2.eastmoney.com/api/qt/clist/get?ut=bd1d9ddb04089700cf9c27f6f7426281&pi=0&pz=100&po=1&fid=f62&fs=b:%s&&fields=f2,f3,f5,f6,f7,f10,f8,f9,f12,f13,f14,f15,f16,f17,f18,f19,f20,f23,f62,f66&cb=jQuery112408385759504702417_1630941255158&_=1630941255159' % (item['f12'])
#print(url)
ret = requests.get(url)
if ret.status_code == 200:
data =str(ret.content,encoding='utf-8')
data = data.replace('jQuery112408385759504702417_1630941255158(','').strip()
data = data[:-1].replace(")",'')
#print(data)
data = json.loads(data)
if 'data' in data:
data = data['data']
total = int(data['total'])
if total > 100:
total = 100
if 'diff' in data:
data = data['diff']
for i in range(0,total-1,1):
item = data[str(i)]
if item['f14'].upper().find('ST') > -1: # 跳过st股票
continue
if item['f12'].startswith("300"): # 过滤掉创业板
continue
if float(item['f3']) > 960: # 涨停股计数 可能量比没有达到2
total_zhangting = total_zhangting + 1
if item['f10'] < filter_liangbi: # 根据量能比进行过滤
continue
if 'f62' in item and float(item['f62']) > 0 and 'f66' in item and float(item['f66']) > 0 : # 主力流入 超大单流入
#if 'f3' in item and float(item['f3']) > 500: # 上涨
ret_data.append(item)
except Exception as e:
print_except(sys._getframe().f_code.co_name, sys.exc_info(), e)
return ret_data
返回数据样例
{
"f1": 2,
"f2": 955,
"f3": 1002, # 涨幅 (除以100)
"f12": "003035",
"f13": 0,
"f14": "南网能源",
"f47": 734635158.58,
"f62": 465458556.0,
"f62": 465458556.0, # 超大单流入
"f66": 466453472.0, #主力流入
"f69": 4253,
"f72": -994916.0,
"f75": -9,
"f78": -221214204.0,
"f81": -2017,
"f84": -244244356.0,
"f87": -2227,
"f128": null,
"f140": null,
"f141": null,
"f152": 2,
"f184": 4244
}
其他所需要的接口,可以自己通过分析进行抓取
阅读原文