更新依赖
百合会签到改为模拟登陆行为 WebClient导入Cookie修复时间异常问题
This commit is contained in:
@@ -6,7 +6,6 @@ import com.yutou.qqbot.QQBotManager;
|
||||
import com.yutou.qqbot.models.Model;
|
||||
import com.yutou.qqbot.utlis.*;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.Cookie;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
@@ -37,7 +36,7 @@ public class BaiHeHui extends Model {
|
||||
try {
|
||||
if (sign()) {
|
||||
QQBotManager.getInstance().sendMessage(QQBotManager.defGroup, "百合会签到成功");
|
||||
}else{
|
||||
} else {
|
||||
QQBotManager.getInstance().sendMessage(QQBotManager.defGroup, "百合会签到失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -57,19 +56,24 @@ public class BaiHeHui extends Model {
|
||||
JSONArray array = JSON.parseArray(cookie);
|
||||
driver.manage().timeouts().implicitlyWait(10000, TimeUnit.SECONDS);
|
||||
driver.get("https://bbs.yamibo.com/forum.php");
|
||||
driver.manage().deleteAllCookies();
|
||||
login(driver);
|
||||
// driver.manage().deleteAllCookies();
|
||||
/* Thread.sleep(1000);
|
||||
for (Cookie _cookie : WebClient.loadCookie(array)) {
|
||||
System.err.println(_cookie);
|
||||
driver.manage().addCookie(_cookie);
|
||||
}
|
||||
Thread.sleep(100);
|
||||
}*/
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
driver.navigate().refresh();
|
||||
driver.get("https://bbs.yamibo.com/forum.php");
|
||||
for (WebElement element : driver.findElements(By.xpath("//a"))) {
|
||||
if ("打卡签到".equals(element.getText())) {
|
||||
element.click();
|
||||
element.click();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -78,12 +82,24 @@ public class BaiHeHui extends Model {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} finally {
|
||||
driver.close();
|
||||
driver.quit();
|
||||
driver.close();
|
||||
driver.quit();
|
||||
}
|
||||
}
|
||||
|
||||
private void login(WebDriver driver) {
|
||||
driver.get("https://bbs.yamibo.com/member.php?mod=logging&action=login");
|
||||
driver.findElement(By.name("username")).sendKeys("z583819556");
|
||||
driver.findElement(By.name("password")).sendKeys("u8fi4Qfr.5D2wZ5");
|
||||
driver.findElement(By.name("loginsubmit")).submit();
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
new BaiHeHui().sign();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,6 +154,6 @@ public class Tsdm extends Model {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
new Tsdm().tsdmSign();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user