新闻测试
This commit is contained in:
@@ -272,8 +272,9 @@ public class StockService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNewsInfo(String url) {
|
public List<String> getNewsInfo(String url) {
|
||||||
String result = "";
|
String result = "";
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
// 使用Jsoup连接到网页
|
// 使用Jsoup连接到网页
|
||||||
Document doc = Jsoup.connect(url)
|
Document doc = Jsoup.connect(url)
|
||||||
@@ -281,12 +282,14 @@ public class StockService {
|
|||||||
.header("Referer", "https://www.business-standard.com/")
|
.header("Referer", "https://www.business-standard.com/")
|
||||||
.header("Accept-Language", "en-US,en;q=0.9")
|
.header("Accept-Language", "en-US,en;q=0.9")
|
||||||
.get();
|
.get();
|
||||||
//result = doc.html().substring(doc.html().indexOf("articleBody") + 13, doc.html().indexOf(",\"author\":") - 1);
|
result = doc.html().substring(doc.html().indexOf("articleBody") + 13, doc.html().indexOf(",\"author\":") - 1);
|
||||||
result = doc.html();
|
list.add(result);
|
||||||
|
list.add(doc.html().substring(doc.html().indexOf("twitter:description") + 32, doc.html().indexOf("<meta property=\"article:published_time") - 7));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return e.toString();
|
list.add(e.toString());
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
return result;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerResponse getStock(int pageNum, int pageSize, String keyWords, String stockPlate, String stockType,
|
public ServerResponse getStock(int pageNum, int pageSize, String keyWords, String stockPlate, String stockType,
|
||||||
|
|||||||
Reference in New Issue
Block a user