新闻测试

This commit is contained in:
dengli
2024-01-10 10:41:06 +08:00
parent 875d4faf0e
commit a49ad82f3f
3 changed files with 10 additions and 10 deletions

View File

@@ -284,7 +284,7 @@ public class StockService {
.get();
result = doc.html().substring(doc.html().indexOf("articleBody") + 13, doc.html().indexOf(",\"author\":") - 1);
list.add(result);
list.add(doc.html().substring(doc.html().indexOf("twitter:description") + 32, doc.html().indexOf("<meta property=\"article:published_time") - 7));
list.add(doc.html().substring(doc.html().indexOf("twitter:description") + 30, doc.html().indexOf("<meta property=\"article:published_time") - 5));
} catch (Exception e) {
list.add(e.toString());
return list;

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

@@ -174,26 +174,26 @@ public class StockApiController {
String news = stockService.getNews();
List<String> newsList = Arrays.asList(news.split("<a href="));
newsList = newsList.subList(1, newsList.size());
return ServerResponse.createBySuccess(stockService.getNewsInfo("https://www.business-standard.com/markets/news/bajaj-auto-s-m-cap-surpasses-rs-2-trillion-mark-on-rs-4-000-crore-buyback-124010900178_1.html"));
/*newsList.forEach( n -> {
newsList.forEach( n -> {
String contentUrl = n.substring(1, n.indexOf("class=\"img-smllnews\"") - 2);
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);
}
});*/
});
return ServerResponse.createBySuccess();
}
//印度股票时线-K线