沪深基础数据API文档|麦蕊智数MyData|实时、准确、全面、专业的金融数据服务平台 String url = "http://api.mairui.club/hsrl/ssjy/000001/自己申请免费证书"; URL obj = new URL(url); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); // 设置请求类型 con.setRequestMethod("GET"); // 读取响应 BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); System.out.println(in); String inputLine; StringBuilder response = new StringBuilder(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); ObjectMapper mapper = new ObjectMapper(); try { // 将JSON字符串转换为Map Map<String, Object> map = mapper.readValue(inputLine, Map.class); String price = map.get("p").toString(); System.out.println("平安银行最新价格:"+price); // 打印转换后的Map System.out.println(map); } catch (Exception e) { e.printStackTrace(); } } in.close();
获取最新股票价格api
于 2024-10-08 17:54:45 首次发布