Skip to content

Commit

Permalink
0
Browse files Browse the repository at this point in the history
  • Loading branch information
xieshujian committed May 20, 2018
1 parent 8db2c49 commit 5255716
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 22 deletions.
11 changes: 7 additions & 4 deletions config.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
headless = false
chromedriver = C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe
username =
password =
#Sun May 20 13:08:48 CST 2018
password=
amount=3000
headless=false
method=prior
username=
chromedriver=C\:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<minimizeJar>true</minimizeJar>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>cn.justin.jimu.CreditAssign</mainClass>
<mainClass>cn.justin.jimu.Jimu</mainClass>
</transformer>
</transformers>
</configuration>
Expand Down
18 changes: 14 additions & 4 deletions src/main/java/cn/justin/cypt/CryptHelper.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package cn.justin.cypt;

import java.io.UnsupportedEncodingException;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Base64;
import java.util.Properties;

import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
Expand All @@ -14,10 +18,10 @@

public class CryptHelper {

public static void main(String[] args) throws UnsupportedEncodingException {
public static void main(String[] args) throws FileNotFoundException, IOException {
// 密钥的种子,可以是任何形式,本质是字节数组
String strKey = "xxx";
String clearPwd = "xxxx";
String strKey = "username";
String clearPwd = "password";
// 密钥数据
byte[] rawKey = getRawKey(strKey.getBytes());
// 密码的明文
Expand All @@ -30,6 +34,12 @@ public static void main(String[] args) throws UnsupportedEncodingException {
String decryptedPwd = decrypt(encryptedData, strKey);

System.out.println(decryptedPwd);
Properties user = new Properties();
String file="config.txt";
user.load(new FileReader(file));
user.setProperty("username", strKey);
user.setProperty("password", encryptedData);
user.store(new FileWriter(file), null);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,43 @@

import cn.justin.cypt.CryptHelper;

public class CreditAssign {
public class Jimu {
static Properties p = new Properties();

static ChromeDriverService service = null;
static ChromeDriver driver = null;


public static void main(String[] args) throws FileNotFoundException, IOException {

String loginURL = "https://www.jimu.com/User/Login";
p.load(new FileReader("config.txt"));
initDriver();
String username = p.getProperty("username");
String password = CryptHelper.decrypt(p.getProperty("password"), username);
driver.get(loginURL);
driver.findElementById("username").sendKeys(username);
driver.findElementById("password").sendKeys(password);
driver.findElementById("act_login").submit();
String method=p.getProperty("method");
String amount=p.getProperty("amount");

switch(method){
case "assign":
creditAssign();break;
case "prior":
priorInvest(amount);break;

}

}
public static void creditAssign() throws FileNotFoundException, IOException {

String creditAssignURL = "https://box.jimu.com/CreditAssign/List?rate=10&orderIndex=1";

try {
p.load(new FileReader("config.txt"));
initDriver();
String username = p.getProperty("username");
String password = CryptHelper.decrypt(p.getProperty("password"),
username);
driver.get(loginURL);
driver.findElementById("username").sendKeys(username);
driver.findElementById("password").sendKeys(password);
driver.findElementById("act_login").submit();

int count = 0;
List<WebElement> tds = null;


while (true) {
driver.get(creditAssignURL);

Expand Down Expand Up @@ -83,6 +94,60 @@ public static void main(String[] args) throws FileNotFoundException, IOException

}


public static void priorInvest(String amount) throws FileNotFoundException, IOException {

String priorInvestURL = "https://box.jimu.com/Project/List";

try {

int count = 0;
List<WebElement> tds = null;

while (true) {
driver.get(priorInvestURL);

tds = driver.findElementsByPartialLinkText("¿ª±ê");

if (!tds.isEmpty()) {

Collections.shuffle(tds);
for (WebElement td : tds) {

if ("10.5%".equals(td.getText().split("\n")[6])) {

try {
driver.get(td.getAttribute("href"));
//driver.findElementByName("investAmount").sendKeys(amount);
driver.findElementByLinkText("[ȫͶ]").click();;
driver.findElementByTagName("button").submit();

Thread.sleep(100);
driver.findElementById("Contract").click();
driver.findElementById("act_invest_confirm").click();

} catch (Exception e) {
e.printStackTrace();
}
}
}
Toolkit.getDefaultToolkit().beep();
}

System.out.println(count++);
// 5 min
Thread.sleep(1000 * 5 * 1);
}

} catch (Exception e) {
e.printStackTrace();
} finally {
if (service != null)
service.stop();
}

}

private static void initDriver() throws IOException {
String chromedriver = p.getProperty("chromedriver");
boolean headless = Boolean.parseBoolean(p.getProperty("headless"));
Expand Down

0 comments on commit 5255716

Please sign in to comment.