Skip to content

Commit 454bd43

Browse files
authored
Merge pull request #52 from lesstop/digitek-dev
Boss聊天页面Xpath查询元素优化
2 parents 968e3d3 + ff03e25 commit 454bd43

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/main/java/boss/Boss.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class Boss {
5353
static int lastSize;
5454
static Date startDate;
5555
static BossConfig config = BossConfig.init();
56-
static int maxPages = 10;
56+
static int maxPages = 10;
5757

5858
public static void main(String[] args) {
5959
loadData(dataPath);
@@ -408,14 +408,14 @@ private static Integer resumeSubmission(String keyword) {
408408
WebElement send = WAIT.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//button[@type='send']")));
409409
send.click();
410410
SeleniumUtil.sleep(3);
411-
WebElement recruiterNameElement = CHROME_DRIVER.findElement(By.xpath("//p[@class='base-info fl']/span[@class='name']"));
412-
WebElement recruiterTitleElement = CHROME_DRIVER.findElement(By.xpath("//p[@class='base-info fl']/span[@class='base-title']"));
411+
WebElement recruiterNameElement = CHROME_DRIVER.findElement(By.xpath("//div[@class='base-info']/div[@class='name-content']/span[@class='name-text']"));
412+
WebElement recruiterTitleElement = CHROME_DRIVER.findElement(By.xpath("//div[@class='base-info']/span[@class='base-title']"));
413413
String recruiter = recruiterNameElement.getText() + " " + recruiterTitleElement.getText();
414414

415415
WebElement companyElement = null;
416416
try {
417417
// 通过定位父元素后获取第二个 span 元素,获取公司名
418-
companyElement = CHROME_DRIVER.findElement(By.xpath("//p[@class='base-info fl']/span[2]"));
418+
companyElement = CHROME_DRIVER.findElement(By.xpath("//div[@class='base-info']/span[1]"));
419419
} catch (Exception e) {
420420
log.info("获取公司名异常!");
421421
}
@@ -424,9 +424,9 @@ private static Integer resumeSubmission(String keyword) {
424424
company = companyElement.getText();
425425
job.setCompanyName(company);
426426
}
427-
WebElement positionNameElement = CHROME_DRIVER.findElement(By.xpath("//a[@class='position-content']/span[@class='position-name']"));
428-
WebElement salaryElement = CHROME_DRIVER.findElement(By.xpath("//a[@class='position-content']/span[@class='salary']"));
429-
WebElement cityElement = CHROME_DRIVER.findElement(By.xpath("//a[@class='position-content']/span[@class='city']"));
427+
WebElement positionNameElement = CHROME_DRIVER.findElement(By.xpath("//div[@class='left-content']/span[@class='position-name']"));
428+
WebElement salaryElement = CHROME_DRIVER.findElement(By.xpath("//div[@class='left-content']/span[@class='salary']"));
429+
WebElement cityElement = CHROME_DRIVER.findElement(By.xpath("//div[@class='left-content']/span[@class='city']"));
430430
String position = positionNameElement.getText() + " " + salaryElement.getText() + " " + cityElement.getText();
431431
company = company == null ? "未知公司: " + job.getHref() : company;
432432
Boolean imgResume = sendResume(company);

0 commit comments

Comments
 (0)