-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2021-01-11:添加Cloud类型学校自动登录获取cookie版本
- Loading branch information
1 parent
17fc939
commit 93f13c0
Showing
43 changed files
with
1,228 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
host=你的学校host,如https://ccut.campusphere.net | ||
fromail=你的发件邮箱账号,如meethigher@qq.com | ||
fromailPw=你的发件邮箱密码 | ||
key=37.3\u2103\u4EE5\u4E0B,\u5065\u5EB7,\u5426,中文注意采用unicode编码 | ||
id=5201314 | ||
pw=密码 | ||
poi=\u4E2D\u56FD\u5C71\u4E1C\u7701\u6CF0\u5B89\u5E02\u65B0\u6CF0\u5E02,中文注意采用unicode编码 | ||
tomail=你的收件邮箱 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# To change this template, choose Tools | Templates | ||
# and open the template in the editor. | ||
|
||
libs.hamcrest.classpath=\ | ||
${base}/hamcrest-core-1.3.jar | ||
libs.hamcrest.displayName=Hamcrest 1.3 | ||
libs.hamcrest.prop-maven-dependencies=org.hamcrest:hamcrest-core:1.3:jar | ||
libs.junit_4.classpath=\ | ||
${base}/junit-4.12.jar | ||
libs.junit_4.displayName=JUnit 4.12 | ||
libs.junit_4.prop-maven-dependencies=junit:junit:4.12:jar |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package auto_login; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.InputStream; | ||
import java.net.HttpURLConnection; | ||
import java.net.URL; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.Map.Entry; | ||
import net.sourceforge.tess4j.Tesseract; | ||
import net.sourceforge.tess4j.TesseractException; | ||
|
||
/** | ||
* | ||
* CaptchaDecoding 用来识别验证码 | ||
* | ||
* @author kit chen | ||
* @github https://github.com/meethigher | ||
* @blog https://meethigher.top | ||
* @time 2021年1月10日 | ||
*/ | ||
public class CaptchaDecoding { | ||
/** | ||
* 云端下载验证码 | ||
* | ||
* @param url | ||
* @param headers | ||
* @return | ||
*/ | ||
public static File downloadCaptcha(String url, Map<String, String> headers) { | ||
InputStream is = null; | ||
FileOutputStream fos = null; | ||
try { | ||
URL realUrl = new URL(url); | ||
HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection(); | ||
// 必须设置false,否则会自动重定向到目标地址 | ||
conn.setInstanceFollowRedirects(false); | ||
if (headers != null) { | ||
Set<Entry<String, String>> set = headers.entrySet(); | ||
for (Entry<String, String> header : set) { | ||
conn.setRequestProperty(header.getKey(), header.getValue()); | ||
} | ||
} | ||
conn.connect(); | ||
is = conn.getInputStream(); | ||
fos = new FileOutputStream("captcha.jpg"); | ||
byte[] buffer = new byte[1024]; | ||
int length; | ||
while ((length = is.read(buffer)) > 0) { | ||
fos.write(buffer, 0, length); | ||
} | ||
} catch (Exception e) { | ||
System.out.println("读取验证码出错!"); | ||
e.printStackTrace(); | ||
} finally { | ||
try { | ||
if (is != null) | ||
is.close(); | ||
if (fos != null) | ||
fos.close(); | ||
} catch (Exception e2) { | ||
|
||
} | ||
} | ||
return new File("captcha.jpg"); | ||
} | ||
|
||
/** | ||
* 识别验证码 | ||
* | ||
* @param file | ||
* @return | ||
*/ | ||
public static String parseCaptcha(File file) { | ||
Tesseract tess = new Tesseract(); | ||
//开发环境运行时设置 | ||
tess.setDatapath(ClassLoader.getSystemResource("tessdata").getPath().substring(1)); | ||
//jar包运行时设置 | ||
// String tesspath = System.getProperty("user.dir"); | ||
// tess.setDatapath(tesspath+"/tessdata"); | ||
tess.setLanguage("eng"); | ||
try { | ||
return tess.doOCR(file).replace(" ", ""); | ||
} catch (TesseractException e) { | ||
System.out.println("解析验证码出错!"); | ||
e.printStackTrace(); | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package auto_login; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.net.URL; | ||
import java.util.Properties; | ||
|
||
/** | ||
* | ||
* Config 读取配置文件工具类 | ||
* | ||
* @author kit chen | ||
* @github https://github.com/meethigher | ||
* @blog https://meethigher.top | ||
* @time 2021年1月6日 | ||
*/ | ||
public class Config { | ||
private static String host; | ||
private static String id; | ||
private static String pw; | ||
private static String poi; | ||
private static String tomail; | ||
private static String fromail; | ||
private static String fromailPw; | ||
private static String key; | ||
|
||
public static Properties pro; | ||
static { | ||
InputStream is =null; | ||
ClassLoader cl = Config.class.getClassLoader(); | ||
try { | ||
//这个是开发环境运行时设置 | ||
is = cl.getResourceAsStream("collection.properties"); | ||
//这个是jar包时设置 | ||
// is=new FileInputStream(new File("collection.properties")); | ||
pro = new Properties(); | ||
pro.load(is); | ||
host = pro.getProperty("host"); | ||
id = pro.getProperty("id"); | ||
pw = pro.getProperty("pw"); | ||
poi = pro.getProperty("poi"); | ||
tomail = pro.getProperty("tomail"); | ||
fromail = pro.getProperty("fromail"); | ||
fromailPw = pro.getProperty("fromailPw"); | ||
key = pro.getProperty("key"); | ||
} catch (IOException e) { | ||
System.out.println("读取配置文件出现错误"); | ||
e.printStackTrace(); | ||
} finally { | ||
try { | ||
if (is != null) | ||
is.close(); | ||
} catch (IOException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
public static String getHost() { | ||
return host; | ||
} | ||
|
||
public static String getId() { | ||
return id; | ||
} | ||
|
||
public static String getPw() { | ||
return pw; | ||
} | ||
|
||
public static String getPoi() { | ||
return poi; | ||
} | ||
|
||
public static String getTomail() { | ||
return tomail; | ||
} | ||
|
||
public static String getFromail() { | ||
return fromail; | ||
} | ||
|
||
public static String getFromailPw() { | ||
return fromailPw; | ||
} | ||
|
||
public static String getKey() { | ||
return key; | ||
} | ||
} |
Oops, something went wrong.