你应该是没传host
import requests
url ='http://guba.eastmoney.com/interface/GetData.aspx'
form_data={'param':'code=300729','path':'webarticlelist/api/guba/gubainfo','env':2}
headers = {
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Connection': 'keep-alive',
'Content-Length': '69',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Cookie': 'st_si=80426273055812; st_asi=delete; qgqp_b_id=034c32543e0665e60a6abe212df2b999; st_pvi=75577916022409; st_sp=2020-09-02%2019%3A04%3A07; st_inirUrl=http%3A%2F%2Fguba.eastmoney.com%2Flist%2C300729.html; st_sn=3; st_psi=20200902190407540-117001301474-0318188031',
'Host': 'guba.eastmoney.com',
'Origin': 'http://guba.eastmoney.com',
'Referer': 'http://guba.eastmoney.com/list,300729.html',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36',
'X-Requested-With': 'XMLHttpRequest'
}
response = requests.post(url, data=form_data, headers=headers).text
print(response)
# {"bar_rank":0,"stockbar_fans_count":0,"popular_rank":164,"popular_change":-7,"rc":1,"me":"操作成功","time":"0001-01-01T00:00:00"}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…