新闻处理

This commit is contained in:
gs
2024-06-20 14:47:04 +08:00
parent 4b944f9d84
commit 146e9d9bc0
2 changed files with 8 additions and 2 deletions

View File

@@ -265,7 +265,13 @@ 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("<div class=\"short-video-img\">"),doc.html().lastIndexOf("<div class=\"short-video-img\">")+500);
// result = doc.html().substring(doc.html().indexOf("<div class=\"listingstyle_shortvideoimg__0TWuX shortvideoimg\">"),doc.html().lastIndexOf("<div class=\"listingstyle_shortvideoimg__0TWuX shortvideoimg\">")+500);
Elements divElements = doc.select("div.listingstyle_cardlistlist__Cr4Ym");
StringBuilder sb = new StringBuilder();
for (Element divElement : divElements) {
sb.append(divElement.outerHtml()).append("\n");
}
result = sb.toString();
} catch (Exception e) {
return e.toString();
}

View File

@@ -169,7 +169,7 @@ public class StockApiController {
@RequestMapping({"test.do"})
@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();
List<String> newsList = Arrays.asList(news.split("<a href="));
newsList = newsList.subList(1, newsList.size());