Commit e12912e7 authored by 霍传世's avatar 霍传世

归整

parent 9eaa2bb3
......@@ -55,6 +55,7 @@ public class ScriptInterfaceController {
try{
candidateExamList = (excelUtil).parseExcel(file.getInputStream(),CandidateExam.class);
}catch (Exception e){
e.printStackTrace();
log.info("候选导表解析失败");
JSONObject bodyResponse = new JSONObject();
bodyResponse.put("code",500);
......
......@@ -39,15 +39,18 @@ public class SeleniumService {
Integer j = 0;
// 创建WebDriver实例
try {
System.out.println(url);
// 打开目标网页
driver.get(url);
// 等待元素可见
WebDriverWait wait = new WebDriverWait(driver, 20);
WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#full > div.mainBox > div.big-card-con")));
WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#full > div.mainBox > div.big-card-con > div:nth-child(3) > div:nth-child(2)")));
// 提取元素的HTML内容
String elementHtml = element.getAttribute("outerHTML");
System.out.println(elementHtml);
// 使用Jsoup解析HTML
Document doc = Jsoup.parse(elementHtml);
System.out.println(elementHtml);
List<Element> newQBlocks = doc.select(".new-q-block");
Map<String, String> resultMap = new HashMap<>();
// 遍历每个new-q-block元素
......@@ -63,6 +66,7 @@ public class SeleniumService {
resultMap.put(key, value);
}
}
System.out.println(newQBlocks);
// 打印提取的内容
// 将结果保存为JSON文件
String outputFile = "D:/jsonResults/"+candidateExam.getExamConnectCode()+"/"+candidateExam.getCandidateConnectCode()+"_ai.json";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment