【测试】google search
This commit is contained in:
parent
b2d288d584
commit
d963f8910e
|
@ -31,10 +31,6 @@ public class WebSearchServiceImpl implements WebSearchService {
|
||||||
* bing url
|
* bing url
|
||||||
*/
|
*/
|
||||||
private static final String BING_URL = "https://api.bing.microsoft.com/v7.0/search";
|
private static final String BING_URL = "https://api.bing.microsoft.com/v7.0/search";
|
||||||
/**
|
|
||||||
* 腾讯搜索 url
|
|
||||||
*/
|
|
||||||
private static final String TENCENT_URL = "tms.tencentcloudapi.com";
|
|
||||||
|
|
||||||
@Value("${yudao.web-search.api-key:}")
|
@Value("${yudao.web-search.api-key:}")
|
||||||
private String bingApiKey;
|
private String bingApiKey;
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package cn.iocoder.yudao.module.ai.service;
|
package cn.iocoder.yudao.module.ai.service;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.ai.service.websearch.WebSearchServiceImpl;
|
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 com.google.common.collect.Lists;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class WebSearchServiceTests {
|
public class WebSearchServiceTests {
|
||||||
|
@ -13,9 +16,26 @@ public class WebSearchServiceTests {
|
||||||
WebSearchServiceImpl webSearchService = new WebSearchServiceImpl();
|
WebSearchServiceImpl webSearchService = new WebSearchServiceImpl();
|
||||||
Map<String, String> webCrawlerRes = webSearchService.webCrawler(
|
Map<String, String> webCrawlerRes = webSearchService.webCrawler(
|
||||||
Lists.newArrayList("https://tianqi.eastday.com/changsha/40/"));
|
Lists.newArrayList("https://tianqi.eastday.com/changsha/40/"));
|
||||||
|
|
||||||
for (Map.Entry<String, String> entry : webCrawlerRes.entrySet()) {
|
for (Map.Entry<String, String> entry : webCrawlerRes.entrySet()) {
|
||||||
System.err.println(entry.getValue());
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue