Skip to content

Commit 5b06ba8

Browse files
committed
集成auto-homework项目
1 parent f75e46c commit 5b06ba8

14 files changed

Lines changed: 581 additions & 0 deletions

auto-homework/pom.xml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.ossit</groupId>
8+
<artifactId>AutoHomework</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<name>AutoHomework</name>
12+
13+
<url>http://www.example.com</url>
14+
15+
<properties>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
<maven.compiler.source>1.8</maven.compiler.source>
18+
<maven.compiler.target>1.8</maven.compiler.target>
19+
</properties>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>junit</groupId>
24+
<artifactId>junit</artifactId>
25+
<version>4.11</version>
26+
<scope>test</scope>
27+
</dependency>
28+
29+
<!--poi-->
30+
<dependency>
31+
<groupId>org.apache.poi</groupId>
32+
<artifactId>poi</artifactId>
33+
<version>4.1.0</version>
34+
</dependency>
35+
36+
<dependency>
37+
<groupId>org.apache.poi</groupId>
38+
<artifactId>poi-ooxml</artifactId>
39+
<version>4.1.0</version>
40+
</dependency>
41+
42+
43+
44+
45+
<dependency>
46+
<groupId>org.seleniumhq.selenium</groupId>
47+
<artifactId>selenium-java</artifactId>
48+
<version>3.141.59</version>
49+
</dependency>
50+
51+
52+
53+
54+
55+
<!-- <dependency>-->
56+
<!-- <groupId>org.seleniumhq.selenium</groupId>-->
57+
<!-- <artifactId>selenium-chrome-driver</artifactId>-->
58+
<!-- <version>3.141.59</version>-->
59+
<!-- </dependency>-->
60+
61+
62+
63+
</dependencies>
64+
65+
<build>
66+
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
67+
<plugins>
68+
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
69+
<plugin>
70+
<artifactId>maven-clean-plugin</artifactId>
71+
<version>3.1.0</version>
72+
</plugin>
73+
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
74+
<plugin>
75+
<artifactId>maven-resources-plugin</artifactId>
76+
<version>3.0.2</version>
77+
</plugin>
78+
<plugin>
79+
<artifactId>maven-compiler-plugin</artifactId>
80+
<version>3.8.0</version>
81+
</plugin>
82+
<plugin>
83+
<artifactId>maven-surefire-plugin</artifactId>
84+
<version>2.22.1</version>
85+
</plugin>
86+
<plugin>
87+
<artifactId>maven-jar-plugin</artifactId>
88+
<version>3.0.2</version>
89+
</plugin>
90+
<plugin>
91+
<artifactId>maven-install-plugin</artifactId>
92+
<version>2.5.2</version>
93+
</plugin>
94+
<plugin>
95+
<artifactId>maven-deploy-plugin</artifactId>
96+
<version>2.8.2</version>
97+
</plugin>
98+
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
99+
<plugin>
100+
<artifactId>maven-site-plugin</artifactId>
101+
<version>3.7.1</version>
102+
</plugin>
103+
<plugin>
104+
<artifactId>maven-project-info-reports-plugin</artifactId>
105+
<version>3.0.0</version>
106+
</plugin>
107+
</plugins>
108+
</pluginManagement>
109+
</build>
110+
</project>
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
package com.ossit;
2+
3+
import com.ossit.excel.FindString;
4+
import com.ossit.selenium.DoubleRepeat;
5+
import org.openqa.selenium.By;
6+
import org.openqa.selenium.WebDriver;
7+
import org.openqa.selenium.WebElement;
8+
import org.openqa.selenium.chrome.ChromeDriver;
9+
10+
import java.awt.*;
11+
import java.awt.event.InputEvent;
12+
import java.util.List;
13+
import java.util.concurrent.TimeUnit;
14+
15+
16+
public class CrackPhone
17+
{
18+
public static void main( String[] args ) throws AWTException, InterruptedException {
19+
System.setProperty("webdriver.chrome.driver", "/Users/virtualman/IdeaProjects/AutoHomework/src/main/resource/chromedriver");
20+
21+
WebDriver webDriver = new ChromeDriver();
22+
23+
webDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
24+
webDriver.get("http://whois.chinaz.com/reverse?ddlSearchMode=3");
25+
//用户名
26+
27+
int j=1;
28+
int n=0;
29+
int count =0;
30+
int count2 =0;
31+
int num1=0;
32+
//13506128064
33+
int first1=0;
34+
int first2=0;
35+
int first3=0;
36+
for(int i=0;i<=999;i++){
37+
count++;
38+
count2++;
39+
num1++;
40+
41+
if(num1>=10){
42+
num1=0;
43+
}
44+
45+
46+
47+
48+
if(count==10){
49+
n++;
50+
count=0;
51+
}
52+
53+
if(count2==100){
54+
j++;
55+
count2=0;
56+
}
57+
58+
if(n>=10){
59+
n=0;
60+
}
61+
62+
if(j>=10){
63+
j=0;
64+
}
65+
66+
67+
if(("135"+j+""+n+""+num1+""+"28064").equals("13599928064")){
68+
System.out.println("破解完成");
69+
break;
70+
}
71+
72+
73+
74+
75+
76+
final WebElement username = webDriver.findElement(By.xpath("//*[@id=\"host\"]"));
77+
username.sendKeys("135"+j+""+n+""+num1+""+"28064");
78+
79+
80+
final WebElement check = webDriver.findElement(By.xpath("//*[@id=\"search\"]"));
81+
check.click();
82+
83+
final WebElement title = webDriver.findElement(By.xpath("//*[@id=\"ajaxInfo\"]/ul/li[2]"));
84+
if(!(title.getText().equals("暂无相关数据,请核对后再查询。"))){
85+
System.out.println("破解成功");
86+
break;
87+
}
88+
}
89+
90+
91+
92+
93+
} //else if
94+
}
95+
96+
97+
98+
99+
100+
101+
102+
103+
104+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.ossit.excel;
2+
3+
import org.apache.poi.xssf.usermodel.XSSFSheet;
4+
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
5+
6+
import java.io.FileInputStream;
7+
import java.io.IOException;
8+
9+
public class FindString {
10+
11+
public static StringBuilder findString(String fileName,String findContent){
12+
13+
try {
14+
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(new FileInputStream(fileName));
15+
16+
XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0);
17+
18+
int maxRow = xssfSheet.getLastRowNum();
19+
20+
for(int row=0;row <= maxRow;row++){
21+
short lastCellNum = xssfSheet.getRow(row).getLastCellNum();
22+
23+
for(int cellNum = 0;cellNum < lastCellNum;cellNum++){
24+
25+
boolean flag = xssfSheet.getRow(row).getCell(cellNum).toString().contains(findContent);
26+
if(flag){
27+
StringBuilder sb = new StringBuilder(xssfSheet.getRow(row).getCell(cellNum+1).toString());
28+
// String [] str = xssfSheet.getRow(row).getCell(cellNum).toString().split("\n");
29+
return sb;
30+
// for(String st : str){
31+
//
32+
// if(!st.equals("")) {
33+
// System.out.println(st);
34+
// System.out.println("--------------------");
35+
// }
36+
// }
37+
}
38+
39+
}
40+
41+
42+
}
43+
44+
45+
}catch (IOException e){
46+
e.printStackTrace();
47+
48+
}
49+
50+
return null;
51+
}
52+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package com.ossit.selenium;
2+
3+
4+
import com.ossit.excel.FindString;
5+
import org.openqa.selenium.By;
6+
import org.openqa.selenium.WebDriver;
7+
import org.openqa.selenium.WebElement;
8+
import org.openqa.selenium.chrome.ChromeDriver;
9+
10+
import java.util.List;
11+
import java.util.concurrent.TimeUnit;
12+
13+
public class AutoHomework {
14+
15+
16+
17+
public static void main(String[] args) throws InterruptedException {
18+
String fileName = "/Users/virtualman/IdeaProjects/AutoHomework/src/main/resource/互联网营销(专20春)-第一次测验-参考答案.xlsx";
19+
20+
21+
System.setProperty("webdriver.chrome.driver", "/Users/virtualman/IdeaProjects/AutoHomework/src/main/resource/chromedriver");
22+
23+
WebDriver webDriver = new ChromeDriver();
24+
25+
webDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
26+
webDriver.get("http://course.ougd.cn/login/index.php");
27+
//用户名
28+
final WebElement username = webDriver.findElement(By.xpath("//*[@id=\"username\"]"));
29+
username.sendKeys("18160001450873");
30+
31+
32+
//密码
33+
final WebElement password = webDriver.findElement(By.xpath("//*[@id=\"password\"]"));
34+
35+
36+
password.sendKeys("19911228");
37+
//记住密码
38+
webDriver.findElement(By.xpath("//*[@id=\"rememberusername\"]")).click();
39+
40+
41+
//登录
42+
43+
webDriver.findElement(By.xpath("//*[@id=\"loginbtn\"]")).click();
44+
45+
webDriver.findElement(By.xpath("//*[@id=\"nav-drawer\"]/nav/a[22]/div/div/span[2]")).click();
46+
webDriver.findElement(By.xpath("//*[@id=\"region-main\"]/div/div/ul/li[2]/ul/li[4]/a/div/span")).click();
47+
webDriver.findElement(By.xpath("//*[@id=\"module-236409\"]/div/div/div[2]/div/a/span")).click();
48+
//*[@id="module-236467"]/div/div/div[2]/div/a/span
49+
//*[@id="module-236426"]/div/div/div[2]/div/a/span
50+
List<WebElement> element = webDriver.findElements(By.className("btn-secondary"));
51+
52+
for(WebElement wd : element){
53+
54+
if(wd.getText().equals("再次尝试此测验")){
55+
wd.click();
56+
webDriver.findElement(By.xpath("//*[@id=\"id_submitbutton\"]")).click();
57+
}else if(wd.getText().equals("继续上次答题")){
58+
wd.click();
59+
60+
61+
while(webDriver.findElement(By.name("next")).getAttribute("value").equals("下一页")
62+
|| webDriver.findElement(By.name("next")).getAttribute("value").equals("结束答题…")){
63+
64+
DoubleRepeat.doubleRepeat(webDriver, fileName);
65+
66+
}
67+
68+
69+
70+
} //else if
71+
}
72+
73+
74+
75+
76+
}
77+
}

0 commit comments

Comments
 (0)