Java 实现掘金每日自动签到领取矿石奖励
Posted 洛阳泰山
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java 实现掘金每日自动签到领取矿石奖励相关的知识,希望对你有一定的参考价值。
pom文件引入依赖
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.0.1</version>
</dependency>
核心代码示例
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import java.util.List;
public class JueJinSignIn
private static String webDriver = "webdriver.chrome.driver";
private static String webDriverPath ="E:\\\\work_space\\\\reptile\\\\src\\\\main\\\\resources\\\\chromedriver\\\\chromedriver.exe";
private static WebDriver driver = null;
public static void main(String[] args) throws InterruptedException
System.setProperty(webDriver, webDriverPath);
// ChromeOptions
ChromeOptions chromeOptions = new ChromeOptions();
// 设置后台静默模式启动浏览器
// chromeOptions.addArguments("--headless");
//添加用户cookies数据
chromeOptions.addArguments("--user-data-dir=C:\\\\Users\\\\liuya\\\\AppData\\\\Local\\\\Google\\\\Chrome\\\\User Data1");
//启动浏览器
driver = new ChromeDriver(chromeOptions);
while (true)
start();
public static void start() throws InterruptedException
driver.get("https://juejin.cn/");
Thread.sleep(500);
WebElement signedin = driver.findElement(By.xpath("//button[@class='btn signedin-btn']"));
signedin.sendKeys(Keys.ENTER);
Thread.sleep(500);
WebElement signed = driver.findElement(By.xpath("//button[@class='signedin btn']"));
signed.sendKeys(Keys.ENTER);
Thread.sleep(500);
WebElement btn = driver.findElement(By.xpath("//div[@class='btn-area']/button[@class='btn']"));
btn.sendKeys(Keys.ENTER);
Thread.sleep(500);
WebElement LuckyDrawBtn = driver.findElement(By.id("turntable-item-0"));
javascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("arguments[0].scrollIntoView(true);", LuckyDrawBtn);
LuckyDrawBtn.click();
Thread.sleep(500);
System.out.println(driver.getPageSource());
List<WebElement> elements = (List<WebElement>) jse.executeScript("return jQuery.find('.lottery_modal byte-modal lottery_modal_lucky v-transfer-dom')");
WebElement reward= elements.get(0).findElement(By.xpath("//div[@class='wrapper']/button[@class='submit']"));
reward.sendKeys(Keys.ENTER);
//等待24小时
Thread.sleep(24*60*60*1000);
以上是关于Java 实现掘金每日自动签到领取矿石奖励的主要内容,如果未能解决你的问题,请参考以下文章
.NET 5开源项目:b站账号快速升级到 Lv6,每天自动签到,观看,分享,投币视频!
云函数实现网站自动化签到配置详解Web函数/Nodejs/cookie
golang 领取v2ex每日奖励。命令行参数1 =用户名,命令行参数2 =密码。%v2ex_dialy username pwd