首先,同花顺F10信息的数据来源,我们直接获取https的数据,不用啥API,地址来源:
https://basic.10jqka.com.cn/股票代码/
其中股票代码替换成要查询的股票代码即可,例如:https://basic.10jqka.com.cn/600100/
python代码非常简单,也不需要对付反爬虫,
python
import re
import requests
url = "https://basic.10jqka.com.cn/000017/"
# 设置请求头,模拟浏览器访问
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
'Referer': 'https://basic.10jqka.com.cn/'
}
# 发送请求获取页面内容
response = requests.get(url, headers=headers)
response.encoding = 'gbk' # 确保编码正确
# 获取页面文本
html_content = response.text
# 提取所有 stockcode="000017" 的 stockcont 块
pattern_block = r'<div class="stockcont" stockcode="000017"[^>]*>.*?</div>\s*</div>\s*</div>'
matches = re.findall(pattern_block, html_content, re.DOTALL)
if matches:
for i, content in enumerate(matches):
print(f"=== 块 {i+1} ===")
print(content)
else:
print("未找到 stockcode=000017 的块")
###########################################################
"""
这就是简单的,龙虎榜数据模块
"""
然后再根据自己的需要,正则出数据。