爬虫获取A股上市公司信息

import requests
import json

url='http://query.sse.com.cn/security/stock/getStockListData2.do?&jsonCallBack=jsonpCallback81793&isPagination=true&stockCode=&csrcCode=&areaName=&stockType=1&pageHelp.cacheSize=1&pageHelp.beginPage=1&pageHelp.pageSize=25&pageHelp.pageNo=1&_=1531271694633'
headers={'Cookie':'yfx_c_g_u_id_10000042=_ck18071109145317901555880472178; yfx_f_l_v_t_10000042=f_t_1531271693783__r_t_1531271693783__v_t_1531272783524__r_c_0; VISITED_MENU=%5B%228528%22%2C%228464%22%5D',
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36',
'Referer':'http://www.sse.com.cn/assortment/stock/list/share/'
}
response=requests.get(url,headers=headers)
print(response.text)
a='{"content":'+response.text[19:-1]+'}'#去除开都的jsonpCallback81793(和结尾的)
b=json.loads(a)
print(b)
print(a)
# print(response.text[19:])
# print(response.text[19:-1])

 

你可能感兴趣的:(爬虫2)