Python 获取新浪财经数据的案例

data_info = {'num':'200',#股票数目
          'sort':'r3_net', #散户资金流入
          'asc':'0',
          'bankuai':'',
           'shichang':''}
data = urllib.urlencode(data_info)          #格式化数据 
 
data = urllib2.urlopen(url = u"http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/MoneyFlow.ssl_bkzj_ssggzj?page=1",
                         data = data)
 data_in = data.read()[1:-2] 
 data_formt = data_in.split('},')
 for respCmtJson in data_formt:
     respCmtJson_1 = respCmtJson+'}'
     respCmt = re.sub(r"(,?)(\w+?)\s*?:", r"\1'\2':",respCmtJson_1)  
     respCmt = respCmt.replace("'", "\"")
     resp = respCmt.decode('iso-8859-2').encode('utf-8')
     js = json.loads(resp)


你可能感兴趣的:(Python 获取新浪财经数据的案例)