|
发表于 2022-12-12 19:46:47
|
显示全部楼层
本楼为最佳答案
 - 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[response.text.find('{'):response.text.rfind('}')+1])
- data = data["Data"]["LSJZList"]
- lst = []
- for i in data:
- lst.append(i["LJJZ"])
- print(lst)
复制代码 |
|