添加了“智慧树”平台中b站网页浏览任务;
调整了对于`UnknownTaskPointException`的处理逻辑; 添加了视频任务的自动取消暂停功能
This commit is contained in:
@@ -51,9 +51,9 @@ public class ZhsTask {
|
|||||||
log.info("处理第{}个任务点", count.get());
|
log.info("处理第{}个任务点", count.get());
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case "icon-box video" -> handleVideoTask(k);
|
case "icon-box video" -> handleVideoTask(k);
|
||||||
case "icon-box baidu" -> handleWebTask(k);
|
case "icon-box baidu", "icon-box bzhan" -> handleWebTask(k);
|
||||||
case "icon-box book", "icon-box other", "icon-box img" -> handleDocTask(k);
|
case "icon-box book", "icon-box other", "icon-box img" -> handleDocTask(k);
|
||||||
default -> throw new UnknownTaskPointException("未设置处理策略的任务点类型!");
|
default -> throw new UnknownTaskPointException("未设置处理策略的任务点类型: " + v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
driver.findElement(By.xpath("//img[@alt='back']")).click();
|
driver.findElement(By.xpath("//img[@alt='back']")).click();
|
||||||
@@ -62,13 +62,17 @@ public class ZhsTask {
|
|||||||
log.info("任务完成!");
|
log.info("任务完成!");
|
||||||
driver.quit();
|
driver.quit();
|
||||||
break;
|
break;
|
||||||
}catch (WebDriverException e) {
|
} catch (WebDriverException e) {
|
||||||
log.error("\r\n---------------\r\n");
|
log.error("\r\n---------------\r\n");
|
||||||
log.error(e.getLocalizedMessage());
|
log.error(e.getLocalizedMessage());
|
||||||
log.error("\r\n---------------\r\n");
|
log.error("\r\n---------------\r\n");
|
||||||
log.error("Something went wrong, will retry later..");
|
log.error("Something went wrong, will retry later..");
|
||||||
driver.get("https://onlineweb.zhihuishu.com/onlinestuh5");
|
driver.get("https://onlineweb.zhihuishu.com/onlinestuh5");
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
|
} catch (UnknownTaskPointException e) {
|
||||||
|
log.error(e.getLocalizedMessage());
|
||||||
|
driver.quit();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,7 +108,8 @@ public class ZhsTask {
|
|||||||
//开启倍速
|
//开启倍速
|
||||||
try {
|
try {
|
||||||
driver.findElement(By.xpath("//div[@class='speedTab speedTab15']")).click();
|
driver.findElement(By.xpath("//div[@class='speedTab speedTab15']")).click();
|
||||||
}catch (Exception ignored) {}
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
String currentTime = "00:00:00";
|
String currentTime = "00:00:00";
|
||||||
String duration = "00:00:00";
|
String duration = "00:00:00";
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -115,10 +120,15 @@ public class ZhsTask {
|
|||||||
try {
|
try {
|
||||||
currentTime = driver.findElement(By.xpath(".//span[@class='currentTime']")).getText();
|
currentTime = driver.findElement(By.xpath(".//span[@class='currentTime']")).getText();
|
||||||
duration = driver.findElement(By.xpath(".//span[@class='duration']")).getText();
|
duration = driver.findElement(By.xpath(".//span[@class='duration']")).getText();
|
||||||
}catch (Exception ignored) {}
|
WebElement playButton = driver.findElement(By.xpath("//div[@id='playButton']"));
|
||||||
|
if (playButton.getDomAttribute("class").equals("playButton")) {
|
||||||
|
playButton.click();
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
if (currentTime.equals("00:00:00")) {
|
if (currentTime.equals("00:00:00")) {
|
||||||
continue;
|
continue;
|
||||||
}else {
|
} else {
|
||||||
log.info("{}/{}", currentTime, duration);
|
log.info("{}/{}", currentTime, duration);
|
||||||
}
|
}
|
||||||
if (currentTime.equals(duration)) {
|
if (currentTime.equals(duration)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user