Compare commits
No commits in common. "d35431a35d27c91fedeed5714c6b49ff48fa7118" and "f4711d82fb7a47188b5846031b972e3e38eb614f" have entirely different histories.
d35431a35d
...
f4711d82fb
@ -42,6 +42,7 @@ public class QQMessageListener extends SimpleListenerHost {
|
|||||||
Model useModel = (Model) model.getDeclaredConstructor().newInstance();
|
Model useModel = (Model) model.getDeclaredConstructor().newInstance();
|
||||||
if (!useModel.isUserPublic()) {
|
if (!useModel.isUserPublic()) {
|
||||||
if (!QQNumberManager.getManager().isExistsPower(event.getSource().getFromId(), useModel.getUsePowers())) {
|
if (!QQNumberManager.getManager().isExistsPower(event.getSource().getFromId(), useModel.getUsePowers())) {
|
||||||
|
Log.i("用户没有权限",event.getSource().getFromId()+" > "+model.getSimpleName());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,7 @@ package com.yutou.qqbot.MessageEvent;
|
|||||||
import com.yutou.qqbot.QQBotManager;
|
import com.yutou.qqbot.QQBotManager;
|
||||||
import com.yutou.qqbot.QQNumberManager;
|
import com.yutou.qqbot.QQNumberManager;
|
||||||
import com.yutou.qqbot.models.Model;
|
import com.yutou.qqbot.models.Model;
|
||||||
import com.yutou.qqbot.models.WebSign.BaiHeHui;
|
|
||||||
import com.yutou.qqbot.models.WebSign.Tsdm;
|
|
||||||
import com.yutou.qqbot.utlis.AppTools;
|
import com.yutou.qqbot.utlis.AppTools;
|
||||||
import com.yutou.qqbot.utlis.Log;
|
|
||||||
import com.yutou.qqbot.utlis.StringUtils;
|
import com.yutou.qqbot.utlis.StringUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -27,7 +24,6 @@ public class AdminMessage extends Message {
|
|||||||
|
|
||||||
private static final String SHOW="!列表";
|
private static final String SHOW="!列表";
|
||||||
private static final String HELP="!help";
|
private static final String HELP="!help";
|
||||||
private static final String SIGN="!签到";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AdminMessage(Long qq, String msg) {
|
public AdminMessage(Long qq, String msg) {
|
||||||
@ -142,27 +138,6 @@ public class AdminMessage extends Message {
|
|||||||
System.out.println("结束进程");
|
System.out.println("结束进程");
|
||||||
AppTools.exec("cd /home/yutou/public/servier/tools && ./start.sh",null,true,false);
|
AppTools.exec("cd /home/yutou/public/servier/tools && ./start.sh",null,true,false);
|
||||||
}
|
}
|
||||||
case QQCommands.SIGN -> {
|
|
||||||
boolean sign=true;
|
|
||||||
Log.i("开始签到");
|
|
||||||
try{
|
|
||||||
new Tsdm().tsdmSign();
|
|
||||||
}catch (Exception e){
|
|
||||||
sign=false;
|
|
||||||
QQBotManager.getInstance().sendMessage(qq,"tsdm签到失败:"+AppTools.getExceptionString(e));
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
new BaiHeHui().sign();
|
|
||||||
}catch (Exception e){
|
|
||||||
sign=false;
|
|
||||||
QQBotManager.getInstance().sendMessage(qq,"百合会签到失败:"+AppTools.getExceptionString(e));
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if(sign){
|
|
||||||
QQBotManager.getInstance().sendMessage(qq,"签到任务完成");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class QQBotApplication {
|
public class QQBotApplication {
|
||||||
public static final String version="QQBot v.1.1.2";
|
public static final String version="QQBot v.1.0.1";
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(QQBotApplication.class, args);
|
SpringApplication.run(QQBotApplication.class, args);
|
||||||
RedisTools.initRedisPoolSub();
|
RedisTools.initRedisPoolSub();
|
||||||
|
@ -4,7 +4,10 @@ import com.alibaba.fastjson.JSONArray;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.yutou.qqbot.QQBotManager;
|
import com.yutou.qqbot.QQBotManager;
|
||||||
import com.yutou.qqbot.models.Model;
|
import com.yutou.qqbot.models.Model;
|
||||||
import com.yutou.qqbot.utlis.*;
|
import com.yutou.qqbot.utlis.Log;
|
||||||
|
import com.yutou.qqbot.utlis.RedisTools;
|
||||||
|
import com.yutou.qqbot.utlis.StringUtils;
|
||||||
|
import com.yutou.qqbot.utlis.WebClient;
|
||||||
import net.mamoe.mirai.event.events.MessageEvent;
|
import net.mamoe.mirai.event.events.MessageEvent;
|
||||||
import org.openqa.selenium.By;
|
import org.openqa.selenium.By;
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
@ -40,7 +43,7 @@ public class TurnipProphet extends Model {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nowTime=-1;
|
static int nowTime;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isUserPublic() {
|
public boolean isUserPublic() {
|
||||||
@ -153,7 +156,9 @@ public class TurnipProphet extends Model {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (money >= 9 && money <= 660) {
|
if (money >= 9 && money <= 660) {
|
||||||
if (getTime() < 12) {
|
System.out.println("array = " + array);
|
||||||
|
System.out.println("array.size() = " + array.size());
|
||||||
|
if (nowTime < 12) {
|
||||||
array.set(getDay() * 2 - 1, money);
|
array.set(getDay() * 2 - 1, money);
|
||||||
} else {
|
} else {
|
||||||
array.set(getDay() * 2, money);
|
array.set(getDay() * 2, money);
|
||||||
@ -184,9 +189,7 @@ public class TurnipProphet extends Model {
|
|||||||
QQBotManager.getInstance().sendMessage(qq, "已记录,正在预测本周走势...");
|
QQBotManager.getInstance().sendMessage(qq, "已记录,正在预测本周走势...");
|
||||||
|
|
||||||
Map<String, String> map = openTurnip(prices, pattern);
|
Map<String, String> map = openTurnip(prices, pattern);
|
||||||
if(map==null){
|
|
||||||
map=openTurnip(prices,pattern);
|
|
||||||
}
|
|
||||||
String tmp_pattern = sendQQ(map, prices, pattern, qq);
|
String tmp_pattern = sendQQ(map, prices, pattern, qq);
|
||||||
if (!StringUtils.isEmpty(tmp_pattern)) {
|
if (!StringUtils.isEmpty(tmp_pattern)) {
|
||||||
json.put("pattern", tmp_pattern);
|
json.put("pattern", tmp_pattern);
|
||||||
@ -194,20 +197,21 @@ public class TurnipProphet extends Model {
|
|||||||
RedisTools.set(redisKey, json.toJSONString());
|
RedisTools.set(redisKey, json.toJSONString());
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
|
||||||
setData(money, qq);
|
setData(money, qq);
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String sendQQ(Map<String, String> map, String prices, String pattern, long qq) {
|
private String sendQQ(Map<String, String> map, String prices, String pattern, long qq) {
|
||||||
|
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
String url = String.format("https://turnipprophet.io?prices=%s%s",
|
String url = String.format("https://turnipprophet.io?prices=%s%s",
|
||||||
prices,
|
prices,
|
||||||
pattern == null ? "" : "&pattern=" + pattern
|
pattern == null ? "" : "&pattern=" + pattern
|
||||||
);
|
);
|
||||||
QQBotManager.getInstance().sendMessage(qq, "没有结果,请检查数据是否有误。 \n网页预览:\n" + url);
|
QQBotManager.getInstance().sendMessage(qq, "没有结果,请检查数据是否有误。 \n网页预览:" + url);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +221,7 @@ public class TurnipProphet extends Model {
|
|||||||
out.append("预测结果如下:\n");
|
out.append("预测结果如下:\n");
|
||||||
out.append(TurnipData.MODEL).append(prArray.getJSONObject(0).getString(TurnipData.MODEL)).append("\n");
|
out.append(TurnipData.MODEL).append(prArray.getJSONObject(0).getString(TurnipData.MODEL)).append("\n");
|
||||||
out.append(TurnipData.PR).append(prArray.getJSONObject(0).getString(TurnipData.PR)).append("\n");
|
out.append(TurnipData.PR).append(prArray.getJSONObject(0).getString(TurnipData.PR)).append("\n");
|
||||||
out.append("购入价:").append(prices.split("\\.")[0]).append("\n");
|
|
||||||
out.append(TurnipData.MIX).append(map.get(TurnipData.MIX)).append("\n")
|
out.append(TurnipData.MIX).append(map.get(TurnipData.MIX)).append("\n")
|
||||||
.append(TurnipData.MAX).append(map.get(TurnipData.MAX)).append("\n")
|
.append(TurnipData.MAX).append(map.get(TurnipData.MAX)).append("\n")
|
||||||
.append(TurnipData.DAY).append(map.get(TurnipData.DAY)).append("\n")
|
.append(TurnipData.DAY).append(map.get(TurnipData.DAY)).append("\n")
|
||||||
@ -255,12 +259,6 @@ public class TurnipProphet extends Model {
|
|||||||
super.onTime(time);
|
super.onTime(time);
|
||||||
nowTime = Integer.parseInt(time.split(":")[0]);
|
nowTime = Integer.parseInt(time.split(":")[0]);
|
||||||
}
|
}
|
||||||
public int getTime(){
|
|
||||||
if(nowTime==-1){
|
|
||||||
nowTime=Integer.parseInt(AppTools.getHours());
|
|
||||||
}
|
|
||||||
return nowTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getDay() {
|
private int getDay() {
|
||||||
return Calendar.getInstance().get(Calendar.DAY_OF_WEEK) - 1;
|
return Calendar.getInstance().get(Calendar.DAY_OF_WEEK) - 1;
|
||||||
@ -268,7 +266,7 @@ public class TurnipProphet extends Model {
|
|||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
TurnipProphet prophet = new TurnipProphet();
|
TurnipProphet prophet = new TurnipProphet();
|
||||||
prophet.setData(68, 583819556);
|
prophet.setData(88, 583819556);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,14 +284,10 @@ public class TurnipProphet extends Model {
|
|||||||
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
|
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
WebElement element = driver.findElement(By.id("output"));
|
WebElement element = driver.findElement(By.id("output"));
|
||||||
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
|
|
||||||
List<WebElement> list = element.findElements(By.tagName("tr"));
|
List<WebElement> list = element.findElements(By.tagName("tr"));
|
||||||
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
|
|
||||||
JSONObject pr = new JSONObject();
|
JSONObject pr = new JSONObject();
|
||||||
JSONArray array = new JSONArray();
|
JSONArray array = new JSONArray();
|
||||||
if (list.size() == 0) {
|
if (list.size() == 0) {
|
||||||
driver.close();
|
|
||||||
driver.quit();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,24 +324,14 @@ public class TurnipProphet extends Model {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int maxMoney=0;
|
|
||||||
String maxDay=null;
|
|
||||||
for (String key : map.keySet()) {
|
for (String key : map.keySet()) {
|
||||||
if(map.get(key).contains("~")){
|
System.err.println("记录最高日:" + map.get(key) + " > " + key);
|
||||||
for (String s : map.get(key).split("~")) {
|
if (!key.equals(TurnipProphet.TurnipData.MAX) &&
|
||||||
if(Integer.parseInt(s)>maxMoney){
|
map.get(key).contains(map.get(TurnipProphet.TurnipData.MAX))) {
|
||||||
maxMoney=Integer.parseInt(s);
|
map.put(TurnipProphet.TurnipData.DAY, key);
|
||||||
maxDay=key;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
if(Integer.parseInt(map.get(key))>maxMoney){
|
|
||||||
maxMoney=Integer.parseInt(map.get(key));
|
|
||||||
maxDay=key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
map.put(TurnipProphet.TurnipData.DAY, maxDay);
|
|
||||||
pr.put(TurnipProphet.TurnipData.MODEL, array);
|
pr.put(TurnipProphet.TurnipData.MODEL, array);
|
||||||
map.put(TurnipProphet.TurnipData.MODEL, pr.toJSONString());
|
map.put(TurnipProphet.TurnipData.MODEL, pr.toJSONString());
|
||||||
driver.close();
|
driver.close();
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
package com.yutou.qqbot.models.WebSign;
|
package com.yutou.qqbot.models.WebSign;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.yutou.qqbot.QQBotManager;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.yutou.qqbot.models.Model;
|
import com.yutou.qqbot.models.Model;
|
||||||
import com.yutou.qqbot.utlis.*;
|
import com.yutou.qqbot.utlis.ConfigTools;
|
||||||
import org.openqa.selenium.By;
|
import com.yutou.qqbot.utlis.StringUtils;
|
||||||
|
import com.yutou.qqbot.utlis.WebClient;
|
||||||
import org.openqa.selenium.Cookie;
|
import org.openqa.selenium.Cookie;
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
import org.openqa.selenium.WebElement;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public class BaiHeHui extends Model {
|
public class BaiHeHui extends Model {
|
||||||
@Override
|
@Override
|
||||||
@ -26,28 +25,19 @@ public class BaiHeHui extends Model {
|
|||||||
@Override
|
@Override
|
||||||
public void onTime(String time) {
|
public void onTime(String time) {
|
||||||
super.onTime(time);
|
super.onTime(time);
|
||||||
if ("08:10".equals(time)) {
|
if("08:00".equals(time)){
|
||||||
Log.i("开始百合会签到");
|
|
||||||
try {
|
|
||||||
sign();
|
sign();
|
||||||
QQBotManager.getInstance().sendMessage(QQBotManager.defGroup,"百合会签到成功");
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
QQBotManager.getInstance().sendMessage(QQBotManager.defGroup,"百合会签到失败:"+ AppTools.getExceptionString(e));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sign() {
|
private void sign(){
|
||||||
String cookie= ConfigTools.readFile(new File("baihehui.json"));
|
String cookie= ConfigTools.readFile(new File("baihehui.json"));
|
||||||
if(StringUtils.isEmpty(cookie)){
|
if(StringUtils.isEmpty(cookie)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WebDriver driver=WebClient.getInstance().getWebDriver();
|
WebDriver driver=WebClient.getInstance().getWebDriver();
|
||||||
JSONArray array=JSONArray.parseArray(cookie);
|
JSONArray array=JSONArray.parseArray(cookie);
|
||||||
driver.manage().timeouts().implicitlyWait(10000, TimeUnit.SECONDS);
|
driver.get("https://bbs.yamibo.com/plugin.php?id=study_daily_attendance:daily_attendance&fhash=425430f7");
|
||||||
driver.get("https://bbs.yamibo.com/forum.php");
|
|
||||||
driver.manage().deleteAllCookies();
|
|
||||||
for (Cookie _cookie : WebClient.loadCookie(array)) {
|
for (Cookie _cookie : WebClient.loadCookie(array)) {
|
||||||
driver.manage().addCookie(_cookie);
|
driver.manage().addCookie(_cookie);
|
||||||
}
|
}
|
||||||
@ -57,17 +47,10 @@ public class BaiHeHui extends Model {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
driver.navigate().refresh();
|
driver.navigate().refresh();
|
||||||
for (WebElement element : driver.findElements(By.xpath("//a"))) {
|
|
||||||
if("打卡签到".equals(element.getText())){
|
|
||||||
element.click();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
driver.close();
|
|
||||||
driver.quit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
new BaiHeHui().sign();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,21 @@ package com.yutou.qqbot.models.WebSign;
|
|||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.yutou.qqbot.QQBotManager;
|
import com.yutou.qqbot.QQBotManager;
|
||||||
import com.yutou.qqbot.models.Model;
|
import com.yutou.qqbot.models.Model;
|
||||||
import com.yutou.qqbot.utlis.*;
|
import com.yutou.qqbot.utlis.ConfigTools;
|
||||||
|
import com.yutou.qqbot.utlis.StringUtils;
|
||||||
|
import com.yutou.qqbot.utlis.WebClient;
|
||||||
import net.mamoe.mirai.event.events.MessageEvent;
|
import net.mamoe.mirai.event.events.MessageEvent;
|
||||||
import org.openqa.selenium.*;
|
import org.openqa.selenium.By;
|
||||||
|
import org.openqa.selenium.Cookie;
|
||||||
|
import org.openqa.selenium.JavascriptExecutor;
|
||||||
|
import org.openqa.selenium.WebDriver;
|
||||||
|
import org.openqa.selenium.chrome.ChromeDriver;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static com.yutou.qqbot.utlis.WebClient.getOptions;
|
||||||
|
|
||||||
public class Tsdm extends Model {
|
public class Tsdm extends Model {
|
||||||
@Override
|
@Override
|
||||||
public boolean isUserPublic() {
|
public boolean isUserPublic() {
|
||||||
@ -41,14 +49,8 @@ public class Tsdm extends Model {
|
|||||||
public void onTime(String time) {
|
public void onTime(String time) {
|
||||||
super.onTime(time);
|
super.onTime(time);
|
||||||
if("08:00".equals(time)){
|
if("08:00".equals(time)){
|
||||||
Log.i("开始天使动漫签到");
|
|
||||||
try {
|
|
||||||
tsdmSign();
|
tsdmSign();
|
||||||
QQBotManager.getInstance().sendMessage(QQBotManager.defGroup,"已完成天使动漫的签到");
|
QQBotManager.getInstance().sendMessage(QQBotManager.defGroup,"已完成天使动漫的签到");
|
||||||
} catch (Exception e) {
|
|
||||||
QQBotManager.getInstance().sendMessage(QQBotManager.defGroup, "天使动漫签到失败:" + AppTools.getExceptionString(e));
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,18 +63,6 @@ public class Tsdm extends Model {
|
|||||||
WebDriver driver =WebClient.getInstance().getWebDriver();
|
WebDriver driver =WebClient.getInstance().getWebDriver();
|
||||||
driver.get("https://www.tsdm39.net/forum.php");
|
driver.get("https://www.tsdm39.net/forum.php");
|
||||||
getTsdm(array, driver);
|
getTsdm(array, driver);
|
||||||
boolean isSign=false;
|
|
||||||
for (WebElement element : driver.findElements(By.xpath("//a"))) {
|
|
||||||
if(element.getText().contains("签到领奖!")){
|
|
||||||
isSign=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!isSign){
|
|
||||||
driver.close();
|
|
||||||
driver.quit();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
((JavascriptExecutor) driver).executeScript("showWindow('dsu_paulsign', 'plugin.php?id=dsu_paulsign:sign&9b5e8da2')");
|
((JavascriptExecutor) driver).executeScript("showWindow('dsu_paulsign', 'plugin.php?id=dsu_paulsign:sign&9b5e8da2')");
|
||||||
}catch (Exception ignored){
|
}catch (Exception ignored){
|
||||||
@ -82,20 +72,15 @@ public class Tsdm extends Model {
|
|||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
driver.findElement(By.id("wl")).click();
|
driver.findElement(By.id("wl")).click();
|
||||||
driver.findElement(By.xpath("//input[@value='3']")).click();
|
driver.findElement(By.xpath("//input[@value='3']")).click();
|
||||||
driver.findElement(By.id("qiandao")).submit();
|
driver.findElement(By.id("qiandao")).submit();
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
driver.close();
|
driver.close();
|
||||||
driver.quit();
|
driver.quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getTsdm(JSONArray array, WebDriver driver) {
|
private void getTsdm(JSONArray array, WebDriver driver) {
|
||||||
driver.manage().timeouts().implicitlyWait(10000, TimeUnit.SECONDS);
|
driver.manage().timeouts().implicitlyWait(10000, TimeUnit.SECONDS);
|
||||||
driver.manage().deleteAllCookies();
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
@ -31,9 +31,6 @@ public class AppTools {
|
|||||||
public static String getToDayTime() {
|
public static String getToDayTime() {
|
||||||
return new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
return new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||||||
}
|
}
|
||||||
public static String getHours(){
|
|
||||||
return new SimpleDateFormat("HH").format(new Date());
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* 异常输出
|
* 异常输出
|
||||||
*
|
*
|
||||||
|
@ -21,11 +21,9 @@ public class WebClient {
|
|||||||
}
|
}
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebDriver getWebDriver(){
|
public WebDriver getWebDriver(){
|
||||||
return new ChromeDriver(getOptions());
|
return new ChromeDriver(getOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
private WebClient() {
|
private WebClient() {
|
||||||
System.setProperty("webdriver.chrome.driver",
|
System.setProperty("webdriver.chrome.driver",
|
||||||
ConfigTools.load(ConfigTools.CONFIG, "chrome", String.class));
|
ConfigTools.load(ConfigTools.CONFIG, "chrome", String.class));
|
||||||
@ -33,6 +31,11 @@ public class WebClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static List<Cookie> loadCookie(JSONArray array){
|
public static List<Cookie> loadCookie(JSONArray array){
|
||||||
List<Cookie> list=new ArrayList<>();
|
List<Cookie> list=new ArrayList<>();
|
||||||
|
|
||||||
@ -48,7 +51,7 @@ public class WebClient {
|
|||||||
json.getString("value"),
|
json.getString("value"),
|
||||||
json.getString("domain"),
|
json.getString("domain"),
|
||||||
json.getString("path"),
|
json.getString("path"),
|
||||||
containsDate ? new Date(t) : new Date(),
|
containsDate? new Date(t):null,
|
||||||
json.getBoolean("secure"),
|
json.getBoolean("secure"),
|
||||||
json.getBoolean("httpOnly")
|
json.getBoolean("httpOnly")
|
||||||
|
|
||||||
@ -60,8 +63,8 @@ public class WebClient {
|
|||||||
|
|
||||||
public static ChromeOptions getOptions() {
|
public static ChromeOptions getOptions() {
|
||||||
ChromeOptions options = new ChromeOptions();
|
ChromeOptions options = new ChromeOptions();
|
||||||
options.addArguments("--disable-gpu");
|
options.addArguments("disable-infobars");
|
||||||
// options.addArguments("blink-settings=imagesEnabled=false");
|
options.addArguments("blink-settings=imagesEnabled=false");
|
||||||
options.addArguments("--headless");
|
options.addArguments("--headless");
|
||||||
options.addArguments("--no-sandbox");
|
options.addArguments("--no-sandbox");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user