importrequests
# 同花顺热榜
# 爬虫的目标URL小时
# url = "https://dq.10jqka.com.cn/fuyao/hot_list_data/out/hot_list/v1/stock?stock_type=a&type=hour&list_type=normal"
# # 爬虫目标24小时
# # 爬虫的目标URL
url="https://dq.10jqka.com.cn/fuyao/hot_list_data/out/hot_list/v1/stock?stock_type=a&type=day&list_type=normal"
# 请求头信息
headers= {
"Accept": "application/json, text/plain, */*",
"Referer": "https://eq.10jqka.com.cn/",
"Sec-Ch-Ua": "\"Google Chrome\";v=\"119\", \"Chromium\";v=\"119\", \"Not?A_Brand\";v=\"24\"",
"Sec-Ch-Ua-Mobile": "?0",
"Sec-Ch-Ua-Platform": "\"Windows\"",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
}
# 发送GET请求
response=requests.get(url, headers=headers)
# 判断响应的状态码
ifresponse.status_code==200:
# 解析响应的内容(JSON格式)
data=response.json()
# 这里可以添加代码来处理数据,例如打印或保存
print(data)
else:
print(f"请求失败,状态码:{response.status_code}")