[Python] 纯文本查看 复制代码 # -*- coding: utf-8 -*-
"""
Created on Thu Dec 8 10:15:59 2022
@author: Administrator
"""
import requests,re,json
cookies = {
'st_si': '25114671169170',
'st_pvi': '57444998705878',
'st_sp': '2022-12-08%2010%3A10%3A59',
'st_inirUrl': '',
'st_sn': '1',
'st_psi': '20221208101059303-112200305283-0587948833',
'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',
'Connection': 'keep-alive',
# Requests sorts cookies= alphabetically
# 'Cookie': 'st_si=25114671169170; st_pvi=57444998705878; st_sp=2022-12-08%2010%3A10%3A59; st_inirUrl=; st_sn=1; st_psi=20221208101059303-112200305283-0587948833; st_asi=delete',
'DNT': '1',
'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.42',
}
params = {
'callback': 'jQuery183022672186565598262_1670465470319',
'fundCode': '515220',
'pageIndex': '1',
'pageSize': '20',
'startDate': '',
'endDate': '',
'_': '1670465470401',
}
response = requests.get('http://api.fund.eastmoney.com/f10/lsjz', params=params, cookies=cookies, headers=headers, verify=False)
data = re.findall('\((.*?)\)',response.text)[0]
data = json.loads(data) |