fix: 时间字段错乱

This commit is contained in:
2024-07-08 12:38:13 +08:00
parent 2446d89b30
commit a403cba964
3 changed files with 4 additions and 3 deletions

View File

@@ -255,7 +255,7 @@ public class StockService {
.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("<div class=\"listingstyle_shortvideoimg__0TWuX shortvideoimg\">"),doc.html().lastIndexOf("<div class=\"listingstyle_shortvideoimg__0TWuX shortvideoimg\">")+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"); Elements divElements = doc.select("div.listingstyle_cardlistlist__dfq57");
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (Element divElement : divElements) { for (Element divElement : divElements) {
sb.append(divElement.outerHtml()).append("\n"); sb.append(divElement.outerHtml()).append("\n");

View File

@@ -179,6 +179,7 @@ public class StockApiController {
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);
// Extract the date and time using regex // Extract the date and time using regex
Pattern pattern = Pattern.compile("Updated On :<!-- --> <!-- -->(.*?)<!-- -->"); Pattern pattern = Pattern.compile("Updated On :<!-- --> <!-- -->(.*?)<!-- -->");
Matcher matcher = pattern.matcher(n); Matcher matcher = pattern.matcher(n);