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

来源:互联网 发布:工程造价在国企知乎 编辑:程序博客网 时间:2024/04/29 00:29
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)


0 0
原创粉丝点击