新增百合会签到(未完成)
移动爬虫代码到对应模块里
This commit is contained in:
parent
bae2939dce
commit
f4711d82fb
@ -5,8 +5,8 @@ import com.yutou.qqbot.models.Animal.TurnipProphet;
|
|||||||
import com.yutou.qqbot.models.Commands.BaiduDown;
|
import com.yutou.qqbot.models.Commands.BaiduDown;
|
||||||
import com.yutou.qqbot.models.Commands.Bangumi;
|
import com.yutou.qqbot.models.Commands.Bangumi;
|
||||||
import com.yutou.qqbot.models.Commands.System.*;
|
import com.yutou.qqbot.models.Commands.System.*;
|
||||||
import com.yutou.qqbot.models.Commands.Tsdm;
|
|
||||||
import com.yutou.qqbot.models.Model;
|
import com.yutou.qqbot.models.Model;
|
||||||
|
import com.yutou.qqbot.models.WebSign.Tsdm;
|
||||||
import com.yutou.qqbot.models.setu.QQSetu;
|
import com.yutou.qqbot.models.setu.QQSetu;
|
||||||
import com.yutou.qqbot.utlis.*;
|
import com.yutou.qqbot.utlis.*;
|
||||||
import net.mamoe.mirai.Bot;
|
import net.mamoe.mirai.Bot;
|
||||||
|
@ -4,13 +4,20 @@ 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.WebDriver;
|
||||||
|
import org.openqa.selenium.WebElement;
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class TurnipProphet extends Model {
|
public class TurnipProphet extends Model {
|
||||||
public static class TurnipData {
|
public static class TurnipData {
|
||||||
@ -94,7 +101,7 @@ public class TurnipProphet extends Model {
|
|||||||
}
|
}
|
||||||
Map<String, String> map = null;
|
Map<String, String> map = null;
|
||||||
try {
|
try {
|
||||||
map = WebClient.getInstance().openTurnip(prices, pattern);
|
map = openTurnip(prices, pattern);
|
||||||
sendQQ(map, prices, pattern, qq);
|
sendQQ(map, prices, pattern, qq);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -181,7 +188,7 @@ public class TurnipProphet extends Model {
|
|||||||
}
|
}
|
||||||
QQBotManager.getInstance().sendMessage(qq, "已记录,正在预测本周走势...");
|
QQBotManager.getInstance().sendMessage(qq, "已记录,正在预测本周走势...");
|
||||||
|
|
||||||
Map<String, String> map = WebClient.getInstance().openTurnip(prices, pattern);
|
Map<String, String> 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)) {
|
||||||
@ -262,6 +269,75 @@ public class TurnipProphet extends Model {
|
|||||||
prophet.setData(88, 583819556);
|
prophet.setData(88, 583819556);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Map<String, String> openTurnip(String prices, String pattern) throws Exception {
|
||||||
|
String url = String.format("https://turnipprophet.io?prices=%s%s",
|
||||||
|
prices,
|
||||||
|
pattern == null ? "" : "&pattern=" + pattern
|
||||||
|
);
|
||||||
|
System.out.println("url = " + url);
|
||||||
|
LinkedHashMap<String, String> map = new LinkedHashMap<>();
|
||||||
|
WebDriver driver =WebClient.getInstance().getWebDriver();
|
||||||
|
|
||||||
|
driver.get(url);
|
||||||
|
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
|
||||||
|
Thread.sleep(500);
|
||||||
|
WebElement element = driver.findElement(By.id("output"));
|
||||||
|
List<WebElement> list = element.findElements(By.tagName("tr"));
|
||||||
|
JSONObject pr = new JSONObject();
|
||||||
|
JSONArray array = new JSONArray();
|
||||||
|
if (list.size() == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (WebElement webElement : list) {
|
||||||
|
String[] tmp;
|
||||||
|
try {
|
||||||
|
tmp = webElement.getText().replace(" ~ ", "~").split(" ");
|
||||||
|
} catch (Exception e) {
|
||||||
|
//e.printStackTrace();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ("所有趋势".equals(tmp[0])) {
|
||||||
|
map.put(TurnipProphet.TurnipData.MONDAY_UP, tmp[3]);
|
||||||
|
map.put(TurnipProphet.TurnipData.MONDAY_DOWN, tmp[4]);
|
||||||
|
map.put(TurnipProphet.TurnipData.TUESDAY_UP, tmp[5]);
|
||||||
|
map.put(TurnipProphet.TurnipData.TUESDAY_DOWN, tmp[6]);
|
||||||
|
map.put(TurnipProphet.TurnipData.WEDNESDAY_UP, tmp[7]);
|
||||||
|
map.put(TurnipProphet.TurnipData.WEDNESDAY_DOWN, tmp[8]);
|
||||||
|
map.put(TurnipProphet.TurnipData.THURSDAY_UP, tmp[9]);
|
||||||
|
map.put(TurnipProphet.TurnipData.THURSDAY_DOWN, tmp[10]);
|
||||||
|
map.put(TurnipProphet.TurnipData.FRIDAY_UP, tmp[11]);
|
||||||
|
map.put(TurnipProphet.TurnipData.FRIDAY_DOWN, tmp[12]);
|
||||||
|
map.put(TurnipProphet.TurnipData.SATURDAY_UP, tmp[13]);
|
||||||
|
map.put(TurnipProphet.TurnipData.SATURDAY_DOWN, tmp[14]);
|
||||||
|
|
||||||
|
map.put(TurnipProphet.TurnipData.MIX, tmp[15]);
|
||||||
|
map.put(TurnipProphet.TurnipData.MAX, tmp[16]);
|
||||||
|
} else {
|
||||||
|
if (!array.toJSONString().contains(tmp[0])) {
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put(TurnipProphet.TurnipData.MODEL, tmp[0]);
|
||||||
|
json.put(TurnipProphet.TurnipData.PR, tmp[1]);
|
||||||
|
array.add(json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (String key : map.keySet()) {
|
||||||
|
System.err.println("记录最高日:" + map.get(key) + " > " + key);
|
||||||
|
if (!key.equals(TurnipProphet.TurnipData.MAX) &&
|
||||||
|
map.get(key).contains(map.get(TurnipProphet.TurnipData.MAX))) {
|
||||||
|
map.put(TurnipProphet.TurnipData.DAY, key);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pr.put(TurnipProphet.TurnipData.MODEL, array);
|
||||||
|
map.put(TurnipProphet.TurnipData.MODEL, pr.toJSONString());
|
||||||
|
driver.close();
|
||||||
|
driver.quit();
|
||||||
|
return map;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
null.90...........
|
null.90...........
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
package com.yutou.qqbot.models.Commands;
|
|
||||||
|
|
||||||
import com.yutou.qqbot.QQBotManager;
|
|
||||||
import com.yutou.qqbot.models.Model;
|
|
||||||
import com.yutou.qqbot.utlis.StringUtils;
|
|
||||||
import com.yutou.qqbot.utlis.WebClient;
|
|
||||||
import net.mamoe.mirai.event.events.MessageEvent;
|
|
||||||
|
|
||||||
public class Tsdm extends Model {
|
|
||||||
@Override
|
|
||||||
public boolean isUserPublic() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] getUsePowers() {
|
|
||||||
return new String[]{
|
|
||||||
QQFromCommands.TSDM_PAY
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
|
|
||||||
super.onMessage(qq, event, isGroup);
|
|
||||||
if(msg.startsWith(QQFromCommands.TSDM_PAY)){
|
|
||||||
String url=msg.replace(QQFromCommands.TSDM_PAY,"").trim();
|
|
||||||
if(StringUtils.isEmpty(url)){
|
|
||||||
QQBotManager.getInstance().sendMessage(qq,"使用说明:!tsdm [url]");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QQBotManager.getInstance().sendMessage(qq,"正在获取,请稍等...");
|
|
||||||
QQBotManager.getInstance().sendMessage(qq,WebClient.getInstance().tsdm(url));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTime(String time) {
|
|
||||||
super.onTime(time);
|
|
||||||
if("08:00".equals(time)){
|
|
||||||
WebClient.getInstance().tsdmSign();
|
|
||||||
QQBotManager.getInstance().sendMessage(QQBotManager.defGroup,"已完成天使动漫的签到");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
56
src/main/java/com/yutou/qqbot/models/WebSign/BaiHeHui.java
Normal file
56
src/main/java/com/yutou/qqbot/models/WebSign/BaiHeHui.java
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
package com.yutou.qqbot.models.WebSign;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.yutou.qqbot.models.Model;
|
||||||
|
import com.yutou.qqbot.utlis.ConfigTools;
|
||||||
|
import com.yutou.qqbot.utlis.StringUtils;
|
||||||
|
import com.yutou.qqbot.utlis.WebClient;
|
||||||
|
import org.openqa.selenium.Cookie;
|
||||||
|
import org.openqa.selenium.WebDriver;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class BaiHeHui extends Model {
|
||||||
|
@Override
|
||||||
|
public boolean isUserPublic() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getUsePowers() {
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTime(String time) {
|
||||||
|
super.onTime(time);
|
||||||
|
if("08:00".equals(time)){
|
||||||
|
sign();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sign(){
|
||||||
|
String cookie= ConfigTools.readFile(new File("baihehui.json"));
|
||||||
|
if(StringUtils.isEmpty(cookie)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
WebDriver driver=WebClient.getInstance().getWebDriver();
|
||||||
|
JSONArray array=JSONArray.parseArray(cookie);
|
||||||
|
driver.get("https://bbs.yamibo.com/plugin.php?id=study_daily_attendance:daily_attendance&fhash=425430f7");
|
||||||
|
for (Cookie _cookie : WebClient.loadCookie(array)) {
|
||||||
|
driver.manage().addCookie(_cookie);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Thread.sleep(500);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
driver.navigate().refresh();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
new BaiHeHui().sign();
|
||||||
|
}
|
||||||
|
}
|
125
src/main/java/com/yutou/qqbot/models/WebSign/Tsdm.java
Normal file
125
src/main/java/com/yutou/qqbot/models/WebSign/Tsdm.java
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
package com.yutou.qqbot.models.WebSign;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.yutou.qqbot.QQBotManager;
|
||||||
|
import com.yutou.qqbot.models.Model;
|
||||||
|
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 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.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static com.yutou.qqbot.utlis.WebClient.getOptions;
|
||||||
|
|
||||||
|
public class Tsdm extends Model {
|
||||||
|
@Override
|
||||||
|
public boolean isUserPublic() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getUsePowers() {
|
||||||
|
return new String[]{
|
||||||
|
QQFromCommands.TSDM_PAY
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
|
||||||
|
super.onMessage(qq, event, isGroup);
|
||||||
|
if(msg.startsWith(QQFromCommands.TSDM_PAY)){
|
||||||
|
String url=msg.replace(QQFromCommands.TSDM_PAY,"").trim();
|
||||||
|
if(StringUtils.isEmpty(url)){
|
||||||
|
QQBotManager.getInstance().sendMessage(qq,"使用说明:!tsdm [url]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QQBotManager.getInstance().sendMessage(qq,"正在获取,请稍等...");
|
||||||
|
QQBotManager.getInstance().sendMessage(qq,tsdm(url));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTime(String time) {
|
||||||
|
super.onTime(time);
|
||||||
|
if("08:00".equals(time)){
|
||||||
|
tsdmSign();
|
||||||
|
QQBotManager.getInstance().sendMessage(QQBotManager.defGroup,"已完成天使动漫的签到");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tsdmSign(){
|
||||||
|
JSONArray array = JSONArray.parseArray(ConfigTools.readFile(new File("cookie.json")));
|
||||||
|
if (array == null) {
|
||||||
|
System.err.println("array is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
WebDriver driver =WebClient.getInstance().getWebDriver();
|
||||||
|
driver.get("https://www.tsdm39.net/forum.php");
|
||||||
|
getTsdm(array, driver);
|
||||||
|
try {
|
||||||
|
((JavascriptExecutor) driver).executeScript("showWindow('dsu_paulsign', 'plugin.php?id=dsu_paulsign:sign&9b5e8da2')");
|
||||||
|
}catch (Exception ignored){
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Thread.sleep(500);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
driver.findElement(By.id("wl")).click();
|
||||||
|
driver.findElement(By.xpath("//input[@value='3']")).click();
|
||||||
|
driver.findElement(By.id("qiandao")).submit();
|
||||||
|
driver.close();
|
||||||
|
driver.quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getTsdm(JSONArray array, WebDriver driver) {
|
||||||
|
driver.manage().timeouts().implicitlyWait(10000, TimeUnit.SECONDS);
|
||||||
|
try {
|
||||||
|
Thread.sleep(500);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
for (Cookie cookie : WebClient.loadCookie(array)) {
|
||||||
|
driver.manage().addCookie(cookie);
|
||||||
|
}
|
||||||
|
driver.navigate().refresh();
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String tsdm(String url) {
|
||||||
|
JSONArray array = JSONArray.parseArray(ConfigTools.readFile(new File("cookie.json")));
|
||||||
|
if (array == null) {
|
||||||
|
System.err.println("array is null");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
WebDriver driver =WebClient.getInstance().getWebDriver();
|
||||||
|
driver.get(url);
|
||||||
|
getTsdm(array, driver);
|
||||||
|
try {
|
||||||
|
((JavascriptExecutor) driver).executeScript("document.getElementsByClassName('y viewpay')[0].click()");
|
||||||
|
try {
|
||||||
|
Thread.sleep(500);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
driver.findElement(By.id("payform")).submit();
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
|
||||||
|
}
|
||||||
|
String body = driver.findElement(By.name("tsdmlz")).getText();
|
||||||
|
driver.close();
|
||||||
|
driver.quit();
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
}
|
@ -8,10 +8,7 @@ import org.openqa.selenium.chrome.ChromeDriver;
|
|||||||
import org.openqa.selenium.chrome.ChromeOptions;
|
import org.openqa.selenium.chrome.ChromeOptions;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class WebClient {
|
public class WebClient {
|
||||||
@ -24,161 +21,47 @@ public class WebClient {
|
|||||||
}
|
}
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
public WebDriver getWebDriver(){
|
||||||
|
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));
|
||||||
// java.util.logging.Logger.getLogger("org.openqa.selenium").setLevel(Level.OFF);
|
// java.util.logging.Logger.getLogger("org.openqa.selenium").setLevel(Level.OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> openTurnip(String prices, String pattern) throws Exception {
|
|
||||||
String url = String.format("https://turnipprophet.io?prices=%s%s",
|
|
||||||
prices,
|
|
||||||
pattern == null ? "" : "&pattern=" + pattern
|
|
||||||
);
|
|
||||||
System.out.println("url = " + url);
|
|
||||||
LinkedHashMap<String, String> map = new LinkedHashMap<>();
|
|
||||||
WebDriver webDriver = new ChromeDriver(getOptions());
|
|
||||||
|
|
||||||
webDriver.get(url);
|
|
||||||
webDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
|
|
||||||
Thread.sleep(500);
|
|
||||||
WebElement element = webDriver.findElement(By.id("output"));
|
|
||||||
List<WebElement> list = element.findElements(By.tagName("tr"));
|
|
||||||
JSONObject pr = new JSONObject();
|
|
||||||
JSONArray array = new JSONArray();
|
|
||||||
if (list.size() == 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (WebElement webElement : list) {
|
|
||||||
String[] tmp;
|
|
||||||
try {
|
|
||||||
tmp = webElement.getText().replace(" ~ ", "~").split(" ");
|
|
||||||
} catch (Exception e) {
|
|
||||||
//e.printStackTrace();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ("所有趋势".equals(tmp[0])) {
|
|
||||||
map.put(TurnipProphet.TurnipData.MONDAY_UP, tmp[3]);
|
|
||||||
map.put(TurnipProphet.TurnipData.MONDAY_DOWN, tmp[4]);
|
|
||||||
map.put(TurnipProphet.TurnipData.TUESDAY_UP, tmp[5]);
|
|
||||||
map.put(TurnipProphet.TurnipData.TUESDAY_DOWN, tmp[6]);
|
|
||||||
map.put(TurnipProphet.TurnipData.WEDNESDAY_UP, tmp[7]);
|
|
||||||
map.put(TurnipProphet.TurnipData.WEDNESDAY_DOWN, tmp[8]);
|
|
||||||
map.put(TurnipProphet.TurnipData.THURSDAY_UP, tmp[9]);
|
|
||||||
map.put(TurnipProphet.TurnipData.THURSDAY_DOWN, tmp[10]);
|
|
||||||
map.put(TurnipProphet.TurnipData.FRIDAY_UP, tmp[11]);
|
|
||||||
map.put(TurnipProphet.TurnipData.FRIDAY_DOWN, tmp[12]);
|
|
||||||
map.put(TurnipProphet.TurnipData.SATURDAY_UP, tmp[13]);
|
|
||||||
map.put(TurnipProphet.TurnipData.SATURDAY_DOWN, tmp[14]);
|
|
||||||
|
|
||||||
map.put(TurnipProphet.TurnipData.MIX, tmp[15]);
|
|
||||||
map.put(TurnipProphet.TurnipData.MAX, tmp[16]);
|
|
||||||
} else {
|
|
||||||
if (!array.toJSONString().contains(tmp[0])) {
|
|
||||||
JSONObject json = new JSONObject();
|
|
||||||
json.put(TurnipProphet.TurnipData.MODEL, tmp[0]);
|
|
||||||
json.put(TurnipProphet.TurnipData.PR, tmp[1]);
|
|
||||||
array.add(json);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (String key : map.keySet()) {
|
|
||||||
System.err.println("记录最高日:" + map.get(key) + " > " + key);
|
|
||||||
if (!key.equals(TurnipProphet.TurnipData.MAX) &&
|
|
||||||
map.get(key).contains(map.get(TurnipProphet.TurnipData.MAX))) {
|
|
||||||
map.put(TurnipProphet.TurnipData.DAY, key);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pr.put(TurnipProphet.TurnipData.MODEL, array);
|
|
||||||
map.put(TurnipProphet.TurnipData.MODEL, pr.toJSONString());
|
|
||||||
webDriver.close();
|
|
||||||
webDriver.quit();
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String tsdm(String url) {
|
|
||||||
JSONArray array = JSONArray.parseArray(ConfigTools.readFile(new File("cookie.json")));
|
|
||||||
if (array == null) {
|
|
||||||
System.err.println("array is null");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
WebDriver driver = new ChromeDriver(getOptions());
|
|
||||||
driver.get(url);
|
|
||||||
getTsdm(array, driver);
|
|
||||||
try {
|
|
||||||
((JavascriptExecutor) driver).executeScript("document.getElementsByClassName('y viewpay')[0].click()");
|
|
||||||
try {
|
|
||||||
Thread.sleep(500);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
driver.findElement(By.id("payform")).submit();
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
|
|
||||||
}
|
|
||||||
String body = driver.findElement(By.name("tsdmlz")).getText();
|
|
||||||
driver.close();
|
|
||||||
driver.quit();
|
|
||||||
return body;
|
|
||||||
}
|
|
||||||
public void tsdmSign(){
|
|
||||||
JSONArray array = JSONArray.parseArray(ConfigTools.readFile(new File("cookie.json")));
|
|
||||||
if (array == null) {
|
|
||||||
System.err.println("array is null");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
WebDriver driver = new ChromeDriver(getOptions());
|
|
||||||
driver.get("https://www.tsdm39.net/forum.php");
|
|
||||||
getTsdm(array, driver);
|
|
||||||
try {
|
|
||||||
((JavascriptExecutor) driver).executeScript("showWindow('dsu_paulsign', 'plugin.php?id=dsu_paulsign:sign&9b5e8da2')");
|
|
||||||
}catch (Exception ignored){
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Thread.sleep(500);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
driver.findElement(By.id("wl")).click();
|
|
||||||
driver.findElement(By.xpath("//input[@value='3']")).click();
|
|
||||||
driver.findElement(By.id("qiandao")).submit();
|
|
||||||
driver.close();
|
|
||||||
driver.quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getTsdm(JSONArray array, WebDriver driver) {
|
public static List<Cookie> loadCookie(JSONArray array){
|
||||||
driver.manage().timeouts().implicitlyWait(10000, TimeUnit.SECONDS);
|
List<Cookie> list=new ArrayList<>();
|
||||||
try {
|
|
||||||
Thread.sleep(500);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
for (Object o : array) {
|
for (Object o : array) {
|
||||||
JSONObject json = (JSONObject) o;
|
JSONObject json = (JSONObject) o;
|
||||||
long t = Long.parseLong(json.getString("expirationDate").replace(".", "")) / 1000;
|
boolean containsDate=json.containsKey("expirationDate");
|
||||||
|
long t=0;
|
||||||
|
if(containsDate) {
|
||||||
|
t = Long.parseLong(json.getString("expirationDate").replace(".", "")) / 1000;
|
||||||
|
}
|
||||||
|
|
||||||
Cookie cookie = new Cookie(json.getString("name"),
|
Cookie cookie = new Cookie(json.getString("name"),
|
||||||
json.getString("value"),
|
json.getString("value"),
|
||||||
json.getString("domain"),
|
json.getString("domain"),
|
||||||
json.getString("path"),
|
json.getString("path"),
|
||||||
new Date(t),
|
containsDate? new Date(t):null,
|
||||||
json.getBoolean("secure"),
|
json.getBoolean("secure"),
|
||||||
json.getBoolean("httpOnly")
|
json.getBoolean("httpOnly")
|
||||||
|
|
||||||
);
|
);
|
||||||
driver.manage().addCookie(cookie);
|
list.add(cookie);
|
||||||
}
|
|
||||||
driver.navigate().refresh();
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChromeOptions getOptions() {
|
public static ChromeOptions getOptions() {
|
||||||
ChromeOptions options = new ChromeOptions();
|
ChromeOptions options = new ChromeOptions();
|
||||||
options.addArguments("disable-infobars");
|
options.addArguments("disable-infobars");
|
||||||
options.addArguments("blink-settings=imagesEnabled=false");
|
options.addArguments("blink-settings=imagesEnabled=false");
|
||||||
@ -189,6 +72,5 @@ public class WebClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
WebClient.getInstance().tsdmSign();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user