Skip to content
wangwaiji edited this page Oct 17, 2018 · 1 revision

''' 获取网页数据 ''' import urllib3 conn_pool=urllib3.PoolManager() response = conn_pool.request('GET', 'http://hq.sinajs.cn/?list=sh601989') hq_str = response.data.decode('GBK') hq_str = hq_str[ hq_str.index('="') + 2:-3 ] hq_field = hq_str.split(',') stock_realtime = { 'name': hq_field[0], 'open': hq_field[1], 'pre_close': hq_field[2] } print(stock_realtime)

Clone this wiki locally