新增印度股票K线,英情接口
This commit is contained in:
@@ -638,6 +638,21 @@ public class StockService {
|
||||
return null;
|
||||
}
|
||||
|
||||
//印度股票时线-K线 英情
|
||||
public ServerResponse getYCTimeK(String codeId) {
|
||||
String sina_result = "";
|
||||
|
||||
try {
|
||||
sina_result = HttpClientRequest.http2Get("https://api.investing.com/api/financialdata/7310/historical/chart/?interval=PT5M&pointscount="+codeId);
|
||||
JSONObject json = JSONObject.parseObject(sina_result).getJSONObject("Time Series (Daily)");
|
||||
|
||||
return ServerResponse.createBySuccess(json);
|
||||
} catch (Exception e) {
|
||||
log.error("获取出错,错误信息 = {}", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//印度股票日线-K线
|
||||
public ServerResponse getDayK(String stockCode) {
|
||||
String sina_result = "";
|
||||
@@ -653,6 +668,21 @@ public class StockService {
|
||||
return null;
|
||||
}
|
||||
|
||||
//印度股票日线-K线
|
||||
public ServerResponse getYQDayK(String codeId) {
|
||||
String sina_result = "";
|
||||
|
||||
try {
|
||||
sina_result = HttpClientRequest.http2Get("https://api.investing.com/api/financialdata/17984/historical/chart/?interval=P1D&pointscount="+codeId);
|
||||
JSONObject json = JSONObject.parseObject(sina_result).getJSONObject("Time Series (Daily)");
|
||||
|
||||
return ServerResponse.createBySuccess(json);
|
||||
} catch (Exception e) {
|
||||
log.error("获取出错,错误信息 = {}", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//印度股票周线-K线
|
||||
public ServerResponse getWeekK(String stockCode) {
|
||||
String sina_result = "";
|
||||
@@ -669,6 +699,21 @@ public class StockService {
|
||||
}
|
||||
|
||||
|
||||
//印度股票周线-K线 英情
|
||||
public ServerResponse getYQWeekK(String codeId) {
|
||||
String sina_result = "";
|
||||
|
||||
try {
|
||||
sina_result = HttpClientRequest.http2Get("https://api.investing.com/api/financialdata/17984/historical/chart/?interval=P1W&pointscount="+codeId);
|
||||
JSONObject json = JSONObject.parseObject(sina_result).getJSONObject("Time Series (Daily)");
|
||||
|
||||
return ServerResponse.createBySuccess(json);
|
||||
} catch (Exception e) {
|
||||
log.error("获取出错,错误信息 = {}", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//印度股票月线-K线
|
||||
public ServerResponse getMonthK(String stockCode) {
|
||||
String sina_result = "";
|
||||
@@ -684,6 +729,21 @@ public class StockService {
|
||||
return null;
|
||||
}
|
||||
|
||||
//印度股票月线-K线 英情
|
||||
public ServerResponse getYQMonthK(String codeId) {
|
||||
String sina_result = "";
|
||||
|
||||
try {
|
||||
sina_result = HttpClientRequest.http2Get("https://api.investing.com/api/financialdata/17984/historical/chart/?interval=P1M&pointscount="+codeId);
|
||||
JSONObject json = JSONObject.parseObject(sina_result).getJSONObject("Time Series (Daily)");
|
||||
|
||||
return ServerResponse.createBySuccess(json);
|
||||
} catch (Exception e) {
|
||||
log.error("获取出错,错误信息 = {}", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ServerResponse getNewStockList() {
|
||||
try {
|
||||
JSONObject jsonParam = new JSONObject();
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.github.pagehelper.StringUtil;
|
||||
import okhttp3.*;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
@@ -73,6 +74,29 @@ public class HttpClientRequest {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static String http2Get(String url) throws IOException {
|
||||
OkHttpClient client = new OkHttpClient.Builder()
|
||||
.protocols(java.util.Arrays.asList(Protocol.HTTP_2, Protocol.HTTP_1_1))
|
||||
.build();
|
||||
Request request = new Request.Builder()
|
||||
.url(url) // 替换为你要请求的URL
|
||||
.addHeader("Cf-Ray", "82e0bc56ccabfabe-SJC")
|
||||
.addHeader("X-Correlation-Id", "a3120e84-ab22-4a03-81bc-270bbb373c1f")
|
||||
.addHeader("Server", "cloudflare")
|
||||
.addHeader("Cf-Cache-Status", "DYNAMIC")
|
||||
.addHeader("Alt-Svc", "h3=\":443\"; ma=86400")
|
||||
.addHeader("Date", "Thu, 30 Nov 2023 05:36:57 GMT")
|
||||
.addHeader("Content-Encoding", "br")
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.addHeader("X-Envoy-Upstream-Service", "434")
|
||||
.addHeader("Via", "1.1 google")
|
||||
.addHeader("X-App-Version", "1.45.3")
|
||||
.addHeader("Cf-Cache-Status", "DYNAMIC")
|
||||
.build();
|
||||
Call call = client.newCall(request);
|
||||
Response response = call.execute();
|
||||
return response.body().string();
|
||||
}
|
||||
/**
|
||||
* 获取cooike
|
||||
* @param url
|
||||
|
||||
Reference in New Issue
Block a user