From 299bc17758d131e8134aca4c422a0dfc89f22d15 Mon Sep 17 00:00:00 2001
From: Yutousama <583819556@qq.com>
Date: Mon, 27 Jun 2022 10:02:47 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BE=9D=E8=B5=96=20?=
=?UTF-8?q?=E7=99=BE=E5=90=88=E4=BC=9A=E7=AD=BE=E5=88=B0=E6=94=B9=E4=B8=BA?=
=?UTF-8?q?=E6=A8=A1=E6=8B=9F=E7=99=BB=E9=99=86=E8=A1=8C=E4=B8=BA=20WebCli?=
=?UTF-8?q?ent=E5=AF=BC=E5=85=A5Cookie=E4=BF=AE=E5=A4=8D=E6=97=B6=E9=97=B4?=
=?UTF-8?q?=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 8 ++---
.../com/yutou/qqbot/QQBotApplication.java | 2 +-
.../yutou/qqbot/models/WebSign/BaiHeHui.java | 34 ++++++++++++++-----
.../com/yutou/qqbot/models/WebSign/Tsdm.java | 2 +-
.../java/com/yutou/qqbot/utlis/WebClient.java | 11 ++++--
5 files changed, 40 insertions(+), 17 deletions(-)
diff --git a/pom.xml b/pom.xml
index c359964..972aaa2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -81,24 +81,24 @@
org.seleniumhq.selenium
selenium-java
- 4.1.4
+ 4.2.1
org.seleniumhq.selenium
selenium-chrome-driver
- 4.1.4
+ 4.2.1
org.seleniumhq.selenium
selenium-api
- 4.1.4
+ 4.2.1
org.seleniumhq.selenium
selenium-remote-driver
- 4.1.4
+ 4.2.1
diff --git a/src/main/java/com/yutou/qqbot/QQBotApplication.java b/src/main/java/com/yutou/qqbot/QQBotApplication.java
index de64df1..99bb40e 100644
--- a/src/main/java/com/yutou/qqbot/QQBotApplication.java
+++ b/src/main/java/com/yutou/qqbot/QQBotApplication.java
@@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class QQBotApplication {
- public static final String version="QQBot v.1.2.28";
+ public static final String version="QQBot v.1.2.29";
public static void main(String[] args) {
System.out.println("version = " + version);
SpringApplication.run(QQBotApplication.class, args);
diff --git a/src/main/java/com/yutou/qqbot/models/WebSign/BaiHeHui.java b/src/main/java/com/yutou/qqbot/models/WebSign/BaiHeHui.java
index 5349625..41dff47 100644
--- a/src/main/java/com/yutou/qqbot/models/WebSign/BaiHeHui.java
+++ b/src/main/java/com/yutou/qqbot/models/WebSign/BaiHeHui.java
@@ -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();
}
}
diff --git a/src/main/java/com/yutou/qqbot/models/WebSign/Tsdm.java b/src/main/java/com/yutou/qqbot/models/WebSign/Tsdm.java
index 90e0402..a07e31c 100644
--- a/src/main/java/com/yutou/qqbot/models/WebSign/Tsdm.java
+++ b/src/main/java/com/yutou/qqbot/models/WebSign/Tsdm.java
@@ -154,6 +154,6 @@ public class Tsdm extends Model {
}
public static void main(String[] args) {
-
+ new Tsdm().tsdmSign();
}
}
diff --git a/src/main/java/com/yutou/qqbot/utlis/WebClient.java b/src/main/java/com/yutou/qqbot/utlis/WebClient.java
index 3b783cd..6e9f960 100644
--- a/src/main/java/com/yutou/qqbot/utlis/WebClient.java
+++ b/src/main/java/com/yutou/qqbot/utlis/WebClient.java
@@ -38,14 +38,21 @@ public class WebClient {
boolean containsDate = json.containsKey("expirationDate");
long t = 0;
if (containsDate) {
- t = Long.parseLong(json.getString("expirationDate").replace(".", "")) / 1000;
+ String _time=json.getString("expirationDate");
+ if(_time.contains(".")){
+ _time =_time.split("\\.")[0];
+ }
+ t = Long.parseLong(_time);
+ }else{
+ t=(System.currentTimeMillis())/1000;
}
+ t*=1000;
Cookie cookie = new Cookie(json.getString("name"),
json.getString("value"),
json.getString("domain"),
json.getString("path"),
- containsDate ? new Date(t) : new Date(),
+ new Date(t),
json.getBooleanValue("secure"),
json.getBooleanValue("httpOnly")