爬取新闻数据测试
This commit is contained in:
@@ -353,12 +353,13 @@ public class StockTask {
|
||||
public void saveStockNews() {
|
||||
String news = stockService.getNews();
|
||||
List<String> newsList = Arrays.asList(news.split("<a href="));
|
||||
newsList = newsList.subList(1, newsList.size());
|
||||
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);
|
||||
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());
|
||||
|
||||
Reference in New Issue
Block a user