1.获取同花顺人气数据代码可用股票ETF可转债
import pandas as pd
import json
import requests
class ths_rq:
def __init__(self):
'''
同花顺人气
'''
pass
def get_headers(self):
'''
请求头
'''
headers={
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0'
}
return headers
def get_hot_stock_rank(self,data_type='大家都在看',date='hour'):
'''
同花顺热股排行
data_dict={'大家都在看':'normal','快速飙升中':'skyrocket',
"技术交易派":"tech",'价值投资派':'value','趋势投资派':'trend'}
date=hour 1小时实时数据
data=day 1天实时数据
只是,快速飙升中,大家都在看才有小时数据
'''
data_dict={'大家都在看':'normal','快速飙升中':'skyrocket',
"技术交易派":"tech",'价值投资派':'value','趋势投资派':'trend'}
list_type=data_dict[data_type]
if list_type=='normal' and date=='hour':
Type='hour'
elif list_type=='skyrocket' and date=='hour':
Type='hour'
if list_type=='normal' and date=='day':
Type='day'
elif list_type=='skyrocket' and date=='day':
Type='hour'
elif list_type=='tech':
Type='day'
elif list_type=='value':
Type='day'
elif list_type=='trend':
Type='day'
else:
pass
url='https://dq.10jqka.com.cn/fuyao/hot_list_data/out/hot_list/v1/stock?'
params={
'stock_type': 'a',
'type': Type,
'list_type': list_type
}
headers=self.get_headers()
res=requests.get(url=url,params=params,headers=headers)
text=res.json()
status_code=text['status_code']
if status_code==0:
标签:hour,同花顺,python,Type,list,headers,ETF,type,day
From: https://blog.csdn.net/weixin_42661541/article/details/142433648