|
|
@@ -1,9 +1,12 @@
|
|
|
package cn.iocoder.yudao.module.ai.service;
|
|
|
|
|
|
import cn.iocoder.yudao.module.ai.service.websearch.WebSearchServiceImpl;
|
|
|
+import cn.iocoder.yudao.module.ai.service.websearch.vo.WebSearchRespVO;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
public class WebSearchServiceTests {
|
|
|
@@ -13,9 +16,26 @@ public class WebSearchServiceTests {
|
|
|
WebSearchServiceImpl webSearchService = new WebSearchServiceImpl();
|
|
|
Map<String, String> webCrawlerRes = webSearchService.webCrawler(
|
|
|
Lists.newArrayList("https://tianqi.eastday.com/changsha/40/"));
|
|
|
-
|
|
|
for (Map.Entry<String, String> entry : webCrawlerRes.entrySet()) {
|
|
|
System.err.println(entry.getValue());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void googleSearchTest() {
|
|
|
+ WebSearchServiceImpl webSearchService = new WebSearchServiceImpl();
|
|
|
+ List<WebSearchRespVO> webSearchRespList = webSearchService.googleSearch("长沙今天天气", 6);
|
|
|
+
|
|
|
+ Map<String, String> webCrawlerRespMap
|
|
|
+ = webSearchService.webCrawler(webSearchRespList.stream().map(WebSearchRespVO::getUrl).toList());
|
|
|
+
|
|
|
+ for (WebSearchRespVO webSearchRespVO : webSearchRespList) {
|
|
|
+ System.err.println(JSON.toJSONString(webSearchRespVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Map.Entry<String, String> entry : webCrawlerRespMap.entrySet()) {
|
|
|
+ System.err.println("url:" + entry.getKey());
|
|
|
+ System.err.println("value" + entry.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|