爬取新闻数据测试
This commit is contained in:
@@ -269,7 +269,7 @@ public class StockService {
|
||||
return ServerResponse.createBySuccessMsg(result);
|
||||
}
|
||||
|
||||
public ServerResponse getNewsInfo(String url) {
|
||||
public String getNewsInfo(String url) {
|
||||
String result = "";
|
||||
try {
|
||||
// 使用Jsoup连接到网页
|
||||
@@ -278,11 +278,11 @@ public class StockService {
|
||||
.header("Referer", "https://www.business-standard.com/")
|
||||
.header("Accept-Language", "en-US,en;q=0.9")
|
||||
.get();
|
||||
result = doc.html().substring(doc.html().indexOf(",\"articleBody\":\"" + 16), doc.html().indexOf(",\"author\""));
|
||||
result = doc.html().substring(doc.html().indexOf("articleBody") + 15,doc.html().indexOf("author") - 5);
|
||||
} catch (Exception e) {
|
||||
return ServerResponse.createByErrorMsg(e.toString());
|
||||
return e.toString();
|
||||
}
|
||||
return ServerResponse.createBySuccessMsg(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public ServerResponse getStock(int pageNum, int pageSize, String keyWords, String stockPlate, String stockType,
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user