@96jennifer 原因找到了
因为param中批量加入引号,引号与内容有空格,
更新代码
import requests
headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36'}
for i in range(1,55):
param = {
'cb': 'jQuery112408933494064226006_1636169759698',
'pn': f'{i}',
'pz': '20',
'po': '1',
'np': '1',
'ut': 'bd1d9ddb04089700cf9c27f6f7426281',
'fltt': '2',
'invt': '2',
'fid': 'f3',
'fs': 'm:0 t:80',
'fields': 'f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152',
'_': '1636169759852'
}
url = "http://90.push2.eastmoney.com/api/qt/clist/get"
r = requests.get(url, params=param, headers=headers)
print(r.text)