def get_xueqiu_stock(): headers = {'X-Requested-With': 'XMLHttpRequest', 'Referer': 'http://xueqiu.com/p/ZH010389', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0', 'Host': 'xueqiu.com', 'cookie':'s=iabht2os.1dgjn9z; xq_a_token=02a16c8dd2d87980d1b3ddced673bd6a74288bde; xq_r_token=024b1e233fea42dd2e0a74832bde2c914ed30e79; __utma=1.2130135756.1433017807.1433017807.1433017807.1;' '__utmc=1; __utmz=1.1433017807.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); Hm_lvt_1db88642e346389874251b5a1eded6e3=1433017809; Hm_lpvt_1db88642e346389874251b5a1eded6e3=1433017809'} c = ['股票代码','股票名称','当前价','涨跌额','涨跌幅','换手率','市盈率','成交量','成交额'] df = pd.DataFrame(columns=c) #for u in range(1,60): url = 'https://xueqiu.com/service/v5/stock/screener/quote/list?page='+str(1)+'&size=5000&order=desc&orderby=percent&order_by=percent&market=CN&type=sh_sz' #print(u) response = requests.get(url,headers=headers) res_dict = json.loads(response.text) list_lsit = res_dict['data'] db ={} for item in list_lsit['list']: db['股票代码'] = item['symbol'] db['股票名称'] = item['name'] db['当前价'] = item['current'] db['涨跌额'] = item['chg'] db['涨跌幅'] = item['percent'] db['换手率'] = item['turnover_rate'] db['市盈率'] = item['pe_ttm'] db['成交量'] = item['volume'] db['成交额'] = item['amount'] #print(db) df = df.append(db,ignore_index=True) return df