Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Achilles
2024-01-11 09:38:46 +08:00
7 changed files with 94 additions and 14 deletions

View File

@@ -153,7 +153,6 @@ public class InvestingApis {
"Time": "1698055197",
"Url": "/equities/aditya-birla",
"Volume": 3693615
* @param httpClient
* @param currPage
* @param pageSize
* @return
@@ -252,7 +251,35 @@ public class InvestingApis {
.collect(Collectors.toList())
;
}
public List<JSONObject> kIndex(String code,String period, String interval,String type) throws IOException {
if(code == null) {
throw new RuntimeException("找不到股票信息");
}
Date nowDate = new Date();
JSONObject json = InvestingInvokerApis.of().__IndiaIndex(code, period,interval);
return json
.getJSONArray("data")
.stream()
.map(val -> {
JSONArray _ar = (JSONArray) val;
JSONObject item = new JSONObject();
item.put("date", _ar.get(0));
item.put("open", _ar.get(1));
item.put("high", _ar.get(2));
item.put("low", _ar.get(3));
item.put("close", _ar.get(4));
item.put("volume", _ar.get(5));
return item;
}).filter(val -> {
if("day".equalsIgnoreCase(type)) {
return DateUtil.isSameDay(nowDate, new Date(val.getLong("date")));
}
return true;
})
.collect(Collectors.toList())
;
}
public static InvestingApis of() {
return new InvestingApis();
}

View File

@@ -201,6 +201,15 @@ public class InvestingInvokerApis {
String body = httpClient().newCall(builder.build()).execute().body().string();
return JSON.parseObject(body);
}
public JSONObject __IndiaIndex(String code,String period, String interval)throws IOException {
String tmpl = "https://api.investing.com/api/financialdata/{}/historical/chart/?period={}&interval={}&pointscount=160";
String url = StrFormatter.format(tmpl, code, period, interval);
Builder builder = builderGet(url);
String body = httpClient().newCall(builder.build()).execute().body().string();
return JSON.parseObject(body);
}
public static InvestingInvokerApis of() {
return new InvestingInvokerApis();

View File

@@ -71,4 +71,10 @@ public class BtodayStockPO {
/**
* 上次更新时间 */
Date lastUpdateTime;
/** 是否锁定 0否 1是 */
Integer isLock;
/** 是否展示 0是 1否 */
Integer isShow;
}

View File

@@ -117,15 +117,15 @@ public class InvestingTask {
String id = contentUrl.substring(contentUrl.lastIndexOf("-") + 1, contentUrl.lastIndexOf("_"));
String imgUrl = n.substring(n.indexOf("img src=") + 9, n.indexOf("?"));
String time = n.substring(n.indexOf("Last Updated") + 23, n.indexOf("IST") - 9);
String title = n.substring(n.indexOf("html\">") + 6, n.indexOf("<div class=\"short-video-img\">") - 47);
SiteNews siteNews = new SiteNews();
siteNews.setAddTime(new Date());
siteNews.setSourceId(id);
siteNews.setTitle(title);
siteNews.setDescription(time);
siteNews.setImgurl(imgUrl);
siteNews.setContent(stockService.getNewsInfo(contentUrl));
List<String> newsInfo = stockService.getNewsInfo(contentUrl);
siteNews.setContent(newsInfo.get(0));
siteNews.setTitle(newsInfo.get(1));
List<SiteNews> list = newsRepository.findAll(QSiteNewsPO.siteNewsPO.sourceId.eq(id));
if (list.size() == 0) {
newsRepository.save(siteNews);

View File

@@ -261,6 +261,8 @@ public class Scraper {
btodayStock.setSelfUrl(url);
btodayStock.setUrl(detailUrl);
btodayStock.setLastUpdateTime(new Date());
btodayStock.setIsLock(0);
btodayStock.setIsShow(0);
btodayStockRepo.save(btodayStock);
/* if (webInfo != null) {