有没有大师帮写一个爬取基金净值的信息
http://fundf10.eastmoney.com/jjjz_010810.html想爬取这个网页中下图圈出的所有净值数据,主要是他下面又翻页,但点翻页网址的不变的
import requests
import json
cookies = {
'st_si': '66348281762529',
'st_pvi': '63968711429536',
'st_sp': '2022-12-12%2021%3A15%3A52',
'st_inirUrl': '',
'st_sn': '1',
'st_psi': '20221212211552388-112200305283-4580946598',
'st_asi': 'delete',
}
headers = {
'Accept': '*/*',
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
# 'Cookie': 'st_si=66348281762529; st_pvi=63968711429536; st_sp=2022-12-12%2021%3A15%3A52; st_inirUrl=; st_sn=1; st_psi=20221212211552388-112200305283-4580946598; st_asi=delete',
'Proxy-Connection': 'keep-alive',
'Referer': 'http://fundf10.eastmoney.com/',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.46',
}
# 抓取不同的基金,修改参数即可
params = {
'callback': 'jQuery18301902553614780571_1670850964513',
'fundCode': '010810',
'pageIndex': '1',
'pageSize': '10000',
'startDate': '',
'endDate': '',
'_': '1670850964537',
}
response = requests.get('http://api.fund.eastmoney.com/f10/lsjz', params=params, cookies=cookies, headers=headers, verify=False)
data = json.loads(response.text)
data = data["Data"]["LSJZList"]
lst = []
for i in data:
lst.append(i["LJJZ"])
print(lst)
你仔细看嘛,有个js接口的嘛 ZhKQYu 发表于 2022-12-12 19:46
大神,想请问你一下,params参数里的最后一个键值对 '_': '1670850964537'的值你是怎么看的,我看每个页面的值好像都不一样 13691255250 发表于 2022-12-12 23:09
大神,想请问你一下,params参数里的最后一个键值对 '_': '1670850964537'的值你是怎么看的,我看每个页 ...
可能是哪里动态返回的,不加也没事
params = {
# 'callback': 'jQuery18301902553614780571_1670850964513',
'fundCode': '010810',
'pageIndex': '1',
'pageSize': '10000',
'startDate': '',
'endDate': '',
# '_': '1670850964537',
} 接口在这里自己随便写个程序就下载了
http://api.fund.eastmoney.com/f10/lsjz?callback=jQuery18304937712367452083_1670924388535&fundCode=010810&pageIndex=2&pageSize=20&startDate=&endDate=&_=1670924402259 向大神学习。
页:
[1]