|
|
|
@ -2,6 +2,7 @@ package cn.linghang.mywust.core.parser.undergraduate; |
|
|
|
|
|
|
|
|
|
import cn.linghang.mywust.core.exception.ParseException; |
|
|
|
|
import cn.linghang.mywust.core.parser.Parser; |
|
|
|
|
import cn.linghang.mywust.core.util.JsoupUtil; |
|
|
|
|
import cn.linghang.mywust.model.global.StudentInfo; |
|
|
|
|
import org.jsoup.Jsoup; |
|
|
|
|
import org.jsoup.nodes.Document; |
|
|
|
@ -18,34 +19,34 @@ public class UndergradStudentInfoPageParser implements Parser<StudentInfo> { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Elements studentElements = table.selectXpath(StudentInfoXpath.STUDENT_NUMBER); |
|
|
|
|
String studentNumber = studentElements.isEmpty() ? null : studentElements.get(0).text().replace("学号:", ""); |
|
|
|
|
String studentNumber = JsoupUtil.getElementText(studentElements).replace("学号:", ""); |
|
|
|
|
|
|
|
|
|
Elements collegeElements = table.selectXpath(StudentInfoXpath.COLLEGE); |
|
|
|
|
String college = collegeElements.isEmpty() ? null : collegeElements.get(0).text().replace("院系:", ""); |
|
|
|
|
String college = JsoupUtil.getElementText(collegeElements).replace("院系:", ""); |
|
|
|
|
|
|
|
|
|
Elements majorElements = table.selectXpath(StudentInfoXpath.MAJOR); |
|
|
|
|
String major = majorElements.isEmpty() ? null : majorElements.get(0).text().replace("专业:", ""); |
|
|
|
|
String major = JsoupUtil.getElementText(majorElements).replace("专业:", ""); |
|
|
|
|
|
|
|
|
|
Elements classElements = table.selectXpath(StudentInfoXpath.CLASS); |
|
|
|
|
String clazz = classElements.isEmpty() ? null : classElements.get(0).text().replace("班级:", ""); |
|
|
|
|
String clazz = JsoupUtil.getElementText(classElements).replace("班级:", ""); |
|
|
|
|
|
|
|
|
|
Elements nameElements = table.selectXpath(StudentInfoXpath.NAME); |
|
|
|
|
String name = nameElements.isEmpty() ? null : nameElements.get(0).text(); |
|
|
|
|
String name = JsoupUtil.getElementText(nameElements); |
|
|
|
|
|
|
|
|
|
Elements sexElements = table.selectXpath(StudentInfoXpath.SEX); |
|
|
|
|
String sex = sexElements.isEmpty() ? null : sexElements.get(0).text(); |
|
|
|
|
String sex = JsoupUtil.getElementText(sexElements); |
|
|
|
|
|
|
|
|
|
Elements birthdayElements = table.selectXpath(StudentInfoXpath.BIRTHDAY); |
|
|
|
|
String birthday = birthdayElements.isEmpty() ? null : birthdayElements.get(0).text(); |
|
|
|
|
String birthday = JsoupUtil.getElementText(birthdayElements); |
|
|
|
|
|
|
|
|
|
Elements hometownElements = table.selectXpath(StudentInfoXpath.HOMETOWN); |
|
|
|
|
String hometown = hometownElements.isEmpty() ? null : hometownElements.get(0).text(); |
|
|
|
|
String hometown = JsoupUtil.getElementText(hometownElements); |
|
|
|
|
|
|
|
|
|
Elements nationalityElements = table.selectXpath(StudentInfoXpath.NATIONALITY); |
|
|
|
|
String nationality = nationalityElements.isEmpty() ? null : nationalityElements.get(0).text(); |
|
|
|
|
String nationality = JsoupUtil.getElementText(nationalityElements); |
|
|
|
|
|
|
|
|
|
Elements idNumberElements = table.selectXpath(StudentInfoXpath.ID_NUMBER); |
|
|
|
|
String idNumber = idNumberElements.isEmpty() ? null : idNumberElements.get(0).text(); |
|
|
|
|
String idNumber = JsoupUtil.getElementText(idNumberElements); |
|
|
|
|
|
|
|
|
|
return StudentInfo.builder() |
|
|
|
|
.studentNumber(studentNumber) |
|
|
|
|