新闻定时任务测试
This commit is contained in:
@@ -170,30 +170,29 @@ public class StockApiController {
|
|||||||
@RequestMapping({"test.do"})
|
@RequestMapping({"test.do"})
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ServerResponse test(@RequestParam("url") String url, @RequestParam("pageNum") Integer pageNum) {
|
public ServerResponse test(@RequestParam("url") String url, @RequestParam("pageNum") Integer pageNum) {
|
||||||
//String news = stockService.getNews();
|
String news = stockService.getNews();
|
||||||
//List<String> newsList = Arrays.asList(news.split("<a href="));
|
List<String> newsList = Arrays.asList(news.split("<a href="));
|
||||||
//newsList = newsList.subList(1, newsList.size());
|
newsList = newsList.subList(1, newsList.size());
|
||||||
//newsList.forEach( n -> {
|
newsList.forEach( n -> {
|
||||||
// String contentUrl = n.substring(1, n.indexOf("class=\"img-smllnews\"") - 2);
|
String contentUrl = n.substring(1, n.indexOf("class=\"img-smllnews\"") - 2);
|
||||||
// String id = contentUrl.substring(contentUrl.lastIndexOf("-") + 1, contentUrl.lastIndexOf("_"));
|
String id = contentUrl.substring(contentUrl.lastIndexOf("-") + 1, contentUrl.lastIndexOf("_"));
|
||||||
// String imgUrl = n.substring(n.indexOf("img loading=\"lazy\" src=") + 24, n.indexOf("?"));
|
String imgUrl = n.substring(n.indexOf("img loading=\"lazy\" src=") + 24, n.indexOf("?"));
|
||||||
// String time = n.substring(n.indexOf("Last Updated") + 23, n.indexOf("IST") - 9);
|
String time = n.substring(n.indexOf("Last Updated") + 23, n.indexOf("IST") - 9);
|
||||||
//
|
|
||||||
// SiteNews siteNews = new SiteNews();
|
SiteNews siteNews = new SiteNews();
|
||||||
// siteNews.setAddTime(new Date());
|
siteNews.setAddTime(new Date());
|
||||||
// siteNews.setSourceId(id);
|
siteNews.setSourceId(id);
|
||||||
// siteNews.setDescription(time);
|
siteNews.setDescription(time);
|
||||||
// siteNews.setImgurl(imgUrl);
|
siteNews.setImgurl(imgUrl);
|
||||||
// List<String> newsInfo = stockService.getNewsInfo(contentUrl);
|
List<String> newsInfo = stockService.getNewsInfo(contentUrl);
|
||||||
// siteNews.setContent(newsInfo.get(0));
|
siteNews.setContent(newsInfo.get(0));
|
||||||
// siteNews.setTitle(newsInfo.get(1));
|
siteNews.setTitle(newsInfo.get(1));
|
||||||
// List<SiteNews> list = newsRepository.findAll(QSiteNewsPO.siteNewsPO.sourceId.eq(id));
|
List<SiteNews> list = newsRepository.findAll(QSiteNewsPO.siteNewsPO.sourceId.eq(id));
|
||||||
// if (list.size() == 0) {
|
if (list.size() == 0) {
|
||||||
// newsRepository.save(siteNews);
|
newsRepository.save(siteNews);
|
||||||
// }
|
}
|
||||||
//});
|
});
|
||||||
List<String> newsInfo = stockService.getNewsInfo(url);
|
return ServerResponse.createBySuccess();
|
||||||
return ServerResponse.createBySuccess(newsInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//印度股票时线-K线
|
//印度股票时线-K线
|
||||||
|
|||||||
Reference in New Issue
Block a user