Merge branch 'develop' into 'main'

Develop

See merge request india/india_market_java!28
This commit is contained in:
guoshuai
2024-06-20 06:51:01 +00:00
2 changed files with 10 additions and 2 deletions

View File

@@ -30,6 +30,8 @@ import org.apache.commons.lang3.StringUtils;
import cn.stock.market.infrastructure.db.po.QStockPO; import cn.stock.market.infrastructure.db.po.QStockPO;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
@@ -252,7 +254,13 @@ 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("<div class=\"shortvideoimg\" style=\"position:relative\">"),doc.html().lastIndexOf("<div class=\"shortvideoimg\" style=\"position:relative\">")+1200); // 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) { } catch (Exception e) {
return e.toString(); return e.toString();
} }

View File

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