Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
HaiNaAIFaceToFace
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
霍传世
HaiNaAIFaceToFace
Commits
e12912e7
Commit
e12912e7
authored
Feb 12, 2025
by
霍传世
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
归整
parent
9eaa2bb3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
1 deletion
+6
-1
src/main/java/com/yuda/hainafacetofaceai/controller/ScriptInterfaceController.java
...inafacetofaceai/controller/ScriptInterfaceController.java
+1
-0
src/main/java/com/yuda/hainafacetofaceai/service/impl/SeleniumService.java
.../yuda/hainafacetofaceai/service/impl/SeleniumService.java
+5
-1
No files found.
src/main/java/com/yuda/hainafacetofaceai/controller/ScriptInterfaceController.java
View file @
e12912e7
...
...
@@ -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
);
...
...
src/main/java/com/yuda/hainafacetofaceai/service/impl/SeleniumService.java
View file @
e12912e7
...
...
@@ -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"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment